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 {

    int n;
    int[] seg;
    HashMap<Integer, Integer> pos = new HashMap<>();

    public void update(int idx, int val){
        idx += n;
        seg[idx] = val;
        idx /= 2;

        while(idx > 1){
            seg[idx] = Math.max(seg[idx * 2], seg[idx * 2 + 1]);
            idx /= 2; 
        }
    }

    public int query(int l, int r){

        l += n;
        r += n;
        int res = 0;

        while(l < r){
            if(l % 2 == 1){
                res = Math.max(res, seg[l]);
                l++;
            }
            if(r % 2 == 1){
                r--;
                res = Math.max(res, seg[r]);
            }
            l /= 2;
            r /= 2;
        }

        return res;

    }


    public void solve() throws IOException{

        String s1 = in.next();
        String s2 = in.next();

        int n = s1.length();
        int m = s2.length();
        int res = 0;

        for(int i = 1; i <= Math.min(n, m); i++){

            if(n % i == 0 && m % i == 0 
                && s1.substring(0, i).equals(s2.substring(0, i))
                && String.join("", Collections.nCopies(n / i, s1.substring(0, i))).equals(s1) 
                && String.join("", Collections.nCopies(m / i, s2.substring(0, i))).equals(s2)){
                res++;
            }
        }

        out.println(res);
        return;
    }





    public BigInteger gcdBigInt(BigInteger a, BigInteger b){

        if(a.compareTo(BigInteger.valueOf(0L)) == 0){
            return b;
        }else{
            return gcdBigInt(b.mod(a), a);
        }

    }

 
    FastScanner in;
    PrintWriter out;
 
    static class FastScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }
 
        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        String nextLine() throws IOException {
            if (st == null || !st.hasMoreTokens())
                return br.readLine();
            StringBuilder result = new StringBuilder(st.nextToken());
            while (st.hasMoreTokens()) {
                result.append(" ");
                result.append(st.nextToken());
            }
            return result.toString();
        }
 
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
 
    }
 
    void run() throws IOException {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }
 
    public static void main(String[] args) throws IOException{
        new Main().run();
    }
 
    public void printArr(int[] arr){
        for(int i = 0; i < arr.length; i++){
            out.print(arr[i] + " ");
        }
        out.println();
    }
 
    public long gcd(long a, long b){
        if(a == 0) return b;
        return gcd(b % a, a);
    }

    public boolean isPrime(long num){

        if(num == 0 || num == 1){
            return false;
        }

        for(int i = 2; i * i <= num; i++){
            if(num % i == 0){
                return false;
            }
        }

        return true;
    }

    public class Pair<A, B>{
        public A x; 
        public B y;

        Pair(A x, B y){
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair<?, ?> pair = (Pair<?, ?>) o;
            if (!x.equals(pair.x)) return false;
            return y.equals(pair.y);
        }

        @Override
        public int hashCode() {
            int result = x.hashCode();
            result = 31 * result + y.hashCode();
            return result;
        }

    }

    class Tuple{
        int x; int y; int z;
        Tuple(int ix, int iy, int iz){
            x = ix;
            y = iy;
            z = iz;
        }
    }
}
