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.*;
import java.math.*;

 
 public class Main	{
   static class Pair implements Comparable<Pair>{
   int a;
   int b;
   public Pair(int x,int y){a=Math.min(x, y);b=Math.max(x, y);}
   public Pair(){}
   public int compareTo(Pair p){
	 return p.a - a;
   }
@Override
public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + a;
	result = prime * result + b;
//	out.println("hashcode = "+result);
	return result;
}
@Override
public boolean equals(Object obj) {
	Pair cur = (Pair)obj;
	if((a==cur.a && b==cur.b) || (a==cur.b && b==cur.a))return true;
	return false;
}
 }
   static class cell implements Comparable<cell>{
	   int a,b;
	   long dis;
	   public cell(int x,int y,long z) {a=x;b=y;dis=z;}
	   public int compareTo(cell c) {
		   return Long.compare(dis,c.dis);
	   }
   }
static class TrieNode{
	TrieNode left;
	TrieNode right;
	int op;
	int data;
	public TrieNode() {}
}
  public static long gcd(long a,long b)
  {
    if(a<b)

      return gcd(b,a);
    if(b==0)
      return a;
    return gcd(b,a%b);
    
  }
  static long lcm(long a,long b) {
	  return a*b / gcd(a,b);
  }
  //static long ans = 0;
  static long mod = (long)1e8;//(long)(1e9+7);///998244353;
   
    public static void main(String[] args) throws Exception {
       new Thread(null, null, "Anshum Gupta", 99999999) {
            public void run() {
                try {
                    solve();
                } catch(Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }

static long pow(long x,long y){
    if(y == 0)return 1;
    if(y==1)return x;
    long a = pow(x,y/2);
    a = (a*a)%mod;
    if(y%2==0){
        return a;
    }
    return (a*x)%mod;
}

static long mxx;
static int mxN = (int)(3e5+5);
static long[]fact,inv_fact;
static long my_inv(long a) {
	return pow(a,mod-2);
}
static long bin(int a,int b) {
	if(a < b || a<0 || b<0)return 0;
    return ((fact[a]*inv_fact[a-b])%mod * inv_fact[b])%mod;
}
static ArrayList<ArrayList<Integer>>adj;
static boolean[]vis;
//static int[]bfs(int a){
//	Queue<Integer> q = new  LinkedList<Integer>();
//	
//	vis = new boolean[n+1];
//	int[]dis = new int[n+1];
//	q.add(a);
//	dis[a] = 0;
//	vis[a] = true;
//	while(!q.isEmpty()) {
//		int cur = q.poll();
//	//	vis[cur] = true;
//	//	if(cur == b)break;
//		for(int x : adj.get(cur)) {
//			if(vis[x])continue;
//			q.add(x);
//			dis[x] = dis[cur]+1;
//			vis[x] = true;
//		}
//	}
//	return dis;
//}
static int n,m;
static int[]c;
static int[]ans;
static boolean all_eq(String  str,int pos,int inc) {
	char x = str.charAt(pos);
	for(;pos<str.length();pos+=inc) {
		if(str.charAt(pos)!=x)return false;
	}
	return true;
}
 public static void solve() throws Exception {
   // solve the problem here
   MyScanner s = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int tc = 1;//s.nextInt();
        mxx = (long)(1e18+5);
//       fact=new long[mxN];
//       inv_fact = new long[mxN];
//       fact[0]=inv_fact[0]=1L;
//       for(int i=1;i<mxN;i++) {
//    	   fact[i] = (i*fact[i-1])%mod;
//    	   inv_fact[i] = my_inv(fact[i]);
//       }
       
        while(tc-->0){
        	String s1 = s.next();
        	String s2 = s.next();
        	int n = s1.length();
        	int m = s2.length();
        //	out.println(s1+" "+s2);
        	HashMap<String,Boolean> mp = new HashMap<String, Boolean>();
        	for(int j=1;j<=n;j++) {
        		if(n%j!=0)continue;
        		boolean ok = true;
        		for(int i=0;i<j;i++) {
        			if(!all_eq(s1,i,j)) {
        				ok = false;
        				break;
        			}
        		}
        		if(ok)mp.put(s1.substring(0, j), true);
        	}
      //  	out.println(mp.size());
        	int cnt = 0;
        	for(int j=1;j<=m;j++) {
        		if(m%j!=0)continue;
        		boolean ok = true;
        		for(int i=0;i<j;i++) {
        			if(!all_eq(s2,i,j)) {
        				ok = false;
        				break;
        			}
        		}
        		if(ok && mp.containsKey(s2.substring(0, j)))cnt++;
        	}
        	out.println(cnt);
        }
        	
           
        out.flush();
}
 
     
 
 
 
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
 
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
         
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}
