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.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class CODEFORCES {
	private InputStream is;
	private PrintWriter out;

	long Inversex = 0, Inversey = 0;

	void InverseModulo(long a, long m) {
		if (m == 0) {
			Inversex = 1;
			Inversey = 0;
		} else {
			InverseModulo(m, a % m);
			long temp = Inversex;
			Inversex = Inversey;
			Inversey = temp + -(a / m) * Inversey;
		}
	}

	long val(long a, long m) {
		InverseModulo(a, m);
		long kl = (Inversex + mod) % mod;
		Inversex = 0;
		return kl;
	}

	long mod = (long) 1e9 + 7;

	void solve() {
		String a = ns(), b = ns();
		long ha[] = new long[a.length()];
		long hb[] = new long[b.length()];
		long po[] = new long[Math.max(a.length(), b.length()) + 1];
		po[0] = 1;
		for (int i = 1; i < po.length; i++)
			po[i] = po[i - 1] * 26 % mod;
		for (int i = 0; i < a.length(); i++) {
			ha[i] = ((a.charAt(i) + 1 - 'a') * po[i]) % mod;
			if (i != 0)
				ha[i] = (ha[i - 1] + ha[i]) % mod;
		}
		for (int i = 0; i < b.length(); i++) {
			hb[i] = ((b.charAt(i) + 1 - 'a') * po[i]) % mod;
			if (i != 0)
				hb[i] = (hb[i] + hb[i - 1]) % mod;
		}
		TreeSet<Integer> set = new TreeSet<Integer>();
		for (int i = 1; i <= Math.min(a.length(), b.length()); i++) {
			if (a.length() % i == 0 && b.length() % i == 0)
				set.add(i);
		}
		long ans = 0;
		while (!set.isEmpty()) {
			int p = set.pollFirst();
			int k = 0;
			long h = ha[p - 1];
			if (ha[p - 1] != hb[p - 1])
				continue;
			long re = val(po[p], mod);
			long tem = re;
			for (k = p; k < a.length(); k += p) {
				long op = ((ha[p + k - 1] - ha[k - 1] + mod) * tem) % mod;
				if (op != h)
					break;
				tem = (tem * re) % mod;
			}
			if (k == a.length()) {
				tem = re;
				for (k = p; k < b.length(); k += p) {
					long op = ((hb[p + k - 1] - hb[k - 1] + mod) * tem) % mod;
					if (op != h)
						break;
					tem = (tem * re) % mod;
				}
				if (k == b.length())
					ans++;
			}
		}
		out.println(ans);
	}

	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new CODEFORCES().soln();
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}