Vasya has recently learned at school what a number's divisor is and decided to determine a string's divisor. Here is what he came up with.

String a is the divisor of string b if and only if there exists a positive integer x such that if we write out string a consecutively x times, we get string b. For example, string "abab" has two divisors — "ab" and "abab".

Now Vasya wants to write a program that calculates the number of common divisors of two strings. Please help him.

Input

The first input line contains a non-empty string s1.

The second input line contains a non-empty string s2.

Lengths of strings s1 and s2 are positive and do not exceed 105. The strings only consist of lowercase Latin letters.

Output

Print the number of common divisors of strings s1 and s2. 

Examples

Input

abcdabcd
abcdabcdabcdabcd


Output

2


Input

aaa
aa


Output

1

Note

In first sample the common divisors are strings "abcd" and "abcdabcd".

In the second sample the common divisor is a single string "a". String "aa" isn't included in the answer as it isn't a divisor of string "aaa".
import java.io.*;
import java.util.*;

public class CommonDivisors {
	public static void main(String args[]){
		FScanner in = new FScanner();
		PrintWriter out = new PrintWriter(System.out);
		String s1=in.next(),s2=in.next();
		int l1=s1.length(),l2=s2.length();
		int arr[]=new int[l1];int a=0;
		int min =Math.min(l1,l2);

		for(int i=1;i<=min;i++)
		{
			if(l1%i==0&&l2%i==0)
			{
				arr[a++]=i;
			}
		}
		int c=0,f=0;
		

		for(int i=0;i<a;i++)
		{
			if(i==a-1)
				f=1;
			if(check(s1,s2,arr[i],f))
				c++;
			f=0;
		}
			out.println(c);
		
		out.close();
	}

	static boolean check(String s1,String s2,int a,int f)
	{
		String sub=s1.substring(0,a);

		for(int i=0;i<s1.length();i+=a)
		{
			String sub2=s1.substring(i,i+a);
			if(sub.equals(sub2)==false)
				return false;
		}
        	
		for(int i=0;i<s2.length();i+=a)
		{
			String sub1=s2.substring(i,i+a);
			if(sub.equals(sub1)==false)
				return false;
		}
	
		return true;

	}

	static boolean checkprime(int n1)
	{
		if(n1%2==0||n1%3==0)
			return false;
		else 
		{
			for(int i=5;i*i<=n1;i+=6)
			{
				if(n1%i==0||n1%(i+2)==0)
					return false;
			}
			return true;
		}
	}
	
	static class FScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer sb = new StringTokenizer("");

		String next(){
			while(!sb.hasMoreTokens()){
				try{
					sb = new StringTokenizer(br.readLine());
				} catch(IOException e){ }
			}
			return sb.nextToken();
		}
		String nextLine(){
			try{ return br.readLine(); } 
			catch(IOException e) { } return "";
		}

		int nextInt(){
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}

		float nextFloat(){
		return Float.parseFloat(next());
		}
		
		double nextDouble(){
		return Double.parseDouble(next());
		}
	}
}
