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 com.sun.org.apache.xml.internal.security.algorithms.Algorithm;
import java.util.*;
import java.util.Scanner;

import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream; 
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;

import java.math.BigDecimal;
import java.math.BigInteger;
import javax.management.StringValueExp;


public class TheMain {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
//		InputReader in = new InputReader("input.txt");
		PrintWriter out = new PrintWriter(outputStream);
		Scanner sc;
		sc = new Scanner(inputStream);
/*		File file  = new File("input.txt");
		try {
		    sc = new Scanner(file);
 */
		    Task solver = new Task();
		    solver.solve(sc, out);

/*
		     } catch (FileNotFoundException e) {
		    e.printStackTrace();
 		}
 */

		out.close();
	}

}


class Task {
	public void solve(Scanner in, PrintWriter out) {
	    String a = in.next(), b = in.next();
	    if (a.length() > b.length())
		swapString(a,b);
	    int[] divisors = new int[10000];
	    int size = 0, ans = 0, n = b.length();

	    for (int i = 1; i*i <= n; ++i)
		if (n % i == 0) {
		    divisors[size++] = i;
		    if (i != n/i)
			divisors[size++] = n/i;
		}

	    for (int it = 0; it < size; ++it) {
		String tmp = b.substring(0, divisors[it]);
		if (isDivisor(a, tmp, divisors[it]))
		    ans += isDivisor(b, tmp, divisors[it]) ? 1 : 0;
	    }

	    out.println(ans);
	}
	
	public static boolean isDivisor(String s, String sample, int divisor) {
	    int n = s.length();
	    if ( n/divisor * divisor != n)
		return false;
	    String tmp = sample;
	    boolean ok = true;
	    for (int i = 0; i < n/divisor && ok; ++i) {
		if (s.substring(i*divisor, (i+1)*divisor).compareTo(tmp) != 0)
		    ok = false;
	    }
	    return ok;	    
	}

	public static void swapString(String a, String b) {
	    String tmp = a; a = b; b = tmp;
	}
}


class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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