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.math.BigInteger;
import java.util.StringTokenizer;

public class B{
    public static void main(String[] args) throws IOException{
        Solve sol = new Solve();
        InputReader in;
        OutputWriter out;
        in = (debug) ? (new InputReader(new FileReader(fin))) : (new InputReader(new InputStreamReader(System.in)));
        out = (debug) ? (new OutputWriter(new FileWriter(fout))) : (new OutputWriter(new OutputStreamWriter(System.out)));
        int ExitCode = sol.run(in, out);
        in.close(); out.close();
        System.exit(ExitCode);
    }
    static final Boolean debug = false;
    static final String fin = "input.txt";
    static final String fout = "output.txt";
}

class Solve{
    final int inf = (1 << 30);
    final long linf = ((long) 1 << 62);
    final long p = 513;
    public int run(InputReader in, OutputWriter out) throws IOException{
        String s = in.readWord(), t = in.readWord();
        int n = s.length(), m = t.length();
        long h1[] = new long[s.length()], pw1[] = new long[s.length()];
        long h2[] = new long[t.length()], pw2[] = new long[t.length()];
        h1[0] = s.charAt(0); pw1[0] = 1;
        h2[0] = t.charAt(0); pw2[0] = 1;
        for (int i = 1; i < n; i++){
            h1[i] = h1[i-1] * p + s.charAt(i);
            pw1[i] = pw1[i-1] * p;
        }
        for (int i = 1; i < m; i++){
            h2[i] = h2[i-1] * p + t.charAt(i);
            pw2[i] = pw2[i-1] * p;
        }
        int res = 0;
        for (int i = Math.min(n, m); i >= 1; i--){
            if (h2[i-1] != h1[i-1])
                continue;
            boolean flag = true;
            for (int j = i;; j += i){
                if (j == n)
                    break;
                if (j + i - 1 >= n){
                    flag = false;
                    break;
                }
                if (h1[j+i-1] - h1[j-1] * pw1[i] != h1[i-1]){
                    flag = false;
                    break;
                }
            }
            for (int j = i;; j += i){
                if (j == m)
                    break;
                if (j + i - 1 >= m){
                    flag = false;
                    break;
                }
                if (h2[j+i-1] - h2[j-1] * pw2[i] != h1[i-1]){
                    flag = false;
                    break;
                }
            }
            if (flag)
                ++res;
        }
        out.println(res);
        return 0;
    }
}

class InputReader{
    private BufferedReader in;
    public InputReader(java.io.Reader stream){
        this.in = new BufferedReader(stream);
    }
    public String readWord() throws IOException{
        StringBuilder b = new StringBuilder();
        int c; c = in.read();
        while (c >= 0 && c <= ' ')
            c = in.read();
        if (c < 0)
            return "";
        while (c > ' '){
            b.append((char) c);
            c = in.read();
        }
        return b.toString();
    }
    public String readLine() throws IOException{
        return in.readLine();
    }
    public String[] readTokens() throws IOException{
        StringTokenizer s = new StringTokenizer(readLine());
        String res[] = new String[s.countTokens()];
        for (int i = 0; i < res.length; i++)
            res[i] = s.nextToken();
        return res;
    }
    public char readChar() throws IOException{
        int c; c = in.read();
        while (c >= 0 && c <= ' ')
            c = in.read();
        if (c < 0)
            return (char) 0;
        return (char) c;
    }
    public int readInt() throws IOException{
        return Integer.parseInt(readWord());
    }
    public int[] readIntArray(int n) throws IOException{
        int res[] = new int[n];
        for (int i = 0; i < res.length; i++)
            res[i] = readInt();
        return res;
    }
    public int[] readIntArray() throws IOException{
        return readIntArray(readInt());
    }
    public long readLong() throws IOException{
        return Long.parseLong(readWord());
    }
    public long[] readLongArray(int n) throws IOException{
        long res[] = new long[n];
        for (int i = 0; i < res.length; i++)
            res[i] = readLong();
        return res;
    }
    public long[] readLongArray() throws IOException{
        return readLongArray(readInt());
    }
    public double readDouble() throws IOException{
        return Double.parseDouble(readWord());
    }
    public double[] readDoubleArray(int n) throws IOException{
        double res[] = new double[n];
        for (int i = 0; i < res.length; i++)
            res[i] = readDouble();
        return res;
    }
    public double[] readDoubleArray() throws IOException{
        return readDoubleArray(readInt());
    }
    public BigInteger readBigInteger() throws IOException{
        return new BigInteger(readWord());
    }
    public void close() throws IOException{
        in.close();
    }
}

class OutputWriter{
    private PrintWriter out;
    public OutputWriter(java.io.Writer stream) throws IOException{
        this.out = new PrintWriter(stream);
    }
    public OutputWriter(String filename) throws IOException{
        this.out = new PrintWriter(filename);
    }
    public void print(Object...objects){
        for (int i = 0; i < objects.length; i++){
            out.print(objects[i]);
        }
    }
    public void println(Object...objects){
        print(objects);
        out.println();
    }
    public void printf(String f, Object...arg){
        out.printf(f, arg);
    }
    public void close() throws IOException{
        out.close();
    }
}