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.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int n;
    int prime1, prime2;
    int mod1, mod2;
    int[] pow1, pow2;
    int[] h1, h2;

    void init(char[] s) {
        Random rnd = new Random();
        prime1 = BigInteger.valueOf(3000 + rnd.nextInt(500))
                .nextProbablePrime().intValue();
        prime2 = BigInteger.valueOf(4000 + rnd.nextInt(500))
                .nextProbablePrime().intValue();
        mod1 = BigInteger.valueOf((int) 1e9 + rnd.nextInt(500))
                .nextProbablePrime().intValue();
        mod2 = BigInteger.valueOf((int) 1e9 + (int) 1e6 + rnd.nextInt(500))
                .nextProbablePrime().intValue();
        n = s.length;
        pow1 = new int[n];
        pow2 = new int[n];
        pow1[0] = pow2[0] = 1;
        for (int i = 1; i < n; i++) {
            pow1[i] = (int) ((long) pow1[i - 1] * prime1 % mod1);
            pow2[i] = (int) ((long) pow2[i - 1] * prime2 % mod2);
        }
        h1 = new int[n];
        h2 = new int[n];
        h1[0] = h2[0] = s[0];
        for (int i = 1; i < n; i++) {
            h1[i] = (int) ((h1[i - 1] + (long) pow1[i] * s[i]) % mod1);
            h2[i] = (int) ((h2[i - 1] + (long) pow2[i] * s[i]) % mod2);
        }
    }

    long getHash(int L, int R) {
        int hash1 = getHash(L, R, h1, pow1, mod1);
        int hash2 = getHash(L, R, h2, pow2, mod2);
        return ((long) hash1 << 32) | hash2;
    }

    int getHash(int L, int R, int[] h, int[] pow, int mod) {
        int hash = h[R];
        if (L > 0)
            hash -= h[L - 1];
        if (hash < 0)
            hash += mod;
        return (int) ((long) hash * pow[n - R - 1] % mod);
    }

    // s[L1..R1] = s[L2..R2]
    boolean equals(int L1, int R1, int L2, int R2) {
        long hash1 = getHash(L1, R1);
        long hash2 = getHash(L2, R2);
        return hash1 == hash2;
    }

    void solve() throws IOException {
        String s = readString();
        String t = readString();

        int ls = s.length();
        int lt = t.length();

        String concat = s + t;
        int cnt = 0;
        init(concat.toCharArray());
        for (int len = 1; len <= ls; len++) {
            if (ls % len != 0) continue;
            if (lt % len != 0) continue;

            boolean ok = true;
            for (int i = 0; i < concat.length(); i += len) {
                if (!equals(0, len - 1, i, i + len - 1)) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cnt++;
                //System.err.println(len);
            }
        }
        out.println(cnt);

    }


}