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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class D {

	final int MOD = 1000000007;
	final double eps = 1e-12;

	public D () throws IOException {
		String S = sc.next();
		String T = sc.next();
		
		start();

		int [] NS = new int[10000];
		int [] NT = new int[10000];
		int is = 0, it = 0;
		
		int LS = S.length(), LT = T.length();
		
		for (int s = 1; s <= LS; ++s) {
			if (LS % s == 0)
				NS[is++] = s;
		}
		
		for (int t = 1; t <= LT; ++t) {
			if (LT % t == 0)
				NT[it++] = t;
		}
		
		int res = 0;
		for (int i = 0; i < is; ++i) {
			out : for (int j = 0; j < it; ++j)
				if (NS[i] == NT[j])  {
					int L = NS[i];
					if (!S.substring(0, L).equals(T.substring(0, L)))
						continue out;
					for(int s = 0; s < LS/NS[i]; ++s)
						if (!S.substring(0, L).equals(S.substring(s*L, s*L+L)))
							continue out;
					for(int t = 0; t < LT/NT[j]; ++t)
						if (!T.substring(0, L).equals(T.substring(t*L, t*L+L)))
							continue out;
					++res;
				}
		}
		exit(res);
	}

	////////////////////////////////////////////////////////////////////////////////////
	
	static MyScanner sc;
	
	static void print (Object... a) {
		StringBuffer b = new StringBuffer();
		for (Object o : a)
			b.append(" ").append(o);
		System.out.println(b.toString().trim());
	}

	static void exit (Object... a) {
		print(a);
		System.out.flush();
		exit();
	}

	static void exit () {
		System.err.println("------------------");
		System.err.println("Time: " + (millis() - t) / 1000.0);
		System.exit(0);
	}
	
	static class MyScanner {
		String next() throws IOException {
			newLine();
			return line[index++];
		}
		
		char [] nextChars() throws IOException {
			return next().toCharArray();
		}
		
		double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		
		long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		
		String nextLine() throws IOException {
			line = null;
			return r.readLine();
		}
		
		String [] nextStrings() throws IOException {
			line = null;
			return r.readLine().split(" ");
		}
		
		int [] nextInts() throws IOException {
			String [] L = nextStrings();
			int [] res = new int [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Integer.parseInt(L[i]);
			return res;
		}
		
		long [] nextLongs() throws IOException {
			String [] L = nextStrings();
			long [] res = new long [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Long.parseLong(L[i]);
			return res;
		}

		boolean eol() {
			return index == line.length;
		}

		//////////////////////////////////////////////
		
		private final BufferedReader r;

		MyScanner () throws IOException {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}
		
		MyScanner(BufferedReader r) throws IOException { 
			this.r = r;
		}
		
		private String [] line;
		private int index;

		private void newLine() throws IOException {
			if (line == null || eol()) {
				line = r.readLine().split(" ");
				index = 0;
			}
		}		
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	public static void main(String[] args) throws IOException {
		run();
		exit();
	}

	static void start() {
		t = millis();
	}

	static void run () throws IOException {
		sc = new MyScanner ();
		new D();
	}

	static long t;
	
	static long millis() {
		return System.currentTimeMillis();
	}	
}
