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".
#include <bits/stdc++.h>
typedef struct stHT *HashTable;
typedef struct stNode *Node;
long long getHash_sc(int n, int size);
HashTable CreateHashTable_sc(int iTableSize);
void Insert_sc(int n, HashTable H);
int find_sc(int n, HashTable H);
long long getHash_lp(long long n, long long lp[], long long size);
long long find(long long n, long long lp[], long long size);
void Insert_Element_lp(long long n, long long lp[], long long size);
long long find_qp(long long n, long long qp[], long long size);
void Insert_Element_qp(long long n, long long qp[], long long size);
long long getHash_qp(long long n, long long qp[], long long size);
int horner(char arr[], int start, int end, long long int val, int size,
           long long int arr2[]);
long long int hornercalc(char arr[], int start, int end, int size);
int count(char arr[], int end);
int min(int a, int b);
struct stHT {
  long long iTableSize;
  Node *pStart;
};
struct stNode {
  long long iElement;
  Node pNext;
};
long long getHash_sc(int n, int size) { return n % size; }
HashTable CreateHashTable_sc(int iTableSize) {
  struct stHT *H = (struct stHT *)malloc(sizeof(struct stHT));
  H->iTableSize = iTableSize;
  H->pStart = (struct stNode **)malloc(iTableSize * sizeof(Node));
  for (int i = 0; i < iTableSize; i++) {
    H->pStart[i] = (struct stNode *)malloc(sizeof(struct stNode));
    H->pStart[i]->iElement = -1;
    H->pStart[i]->pNext = NULL;
  }
  return H;
}
void Insert_sc(int n, HashTable H) {
  int k = getHash_sc(n, H->iTableSize);
  Node temp;
  temp = (struct stNode *)malloc(sizeof(struct stNode));
  temp->iElement = n;
  temp->pNext = NULL;
  Node traverse;
  traverse = (struct stNode *)malloc(sizeof(struct stNode));
  traverse = H->pStart[k];
  while (traverse->pNext != NULL) {
    traverse = traverse->pNext;
  }
  traverse->pNext = temp;
}
int find_sc(int n, HashTable H) {
  int k = getHash_sc(n, H->iTableSize);
  Node temp;
  temp = (struct stNode *)malloc(sizeof(struct stNode));
  Node traverse;
  traverse = (struct stNode *)malloc(sizeof(struct stNode));
  traverse = H->pStart[k]->pNext;
  int pos = 0;
  int i = 0;
  int flag = 0;
  while (traverse != NULL) {
    if (traverse->iElement == n) {
      pos = i;
      flag = 1;
      break;
    }
    i++;
    traverse = traverse->pNext;
  }
  if (flag == 1) {
    return pos;
  } else {
    return -1;
  }
}
long long getHash_lp(long long n, long long lp[], long long size) {
  return n % size;
}
void Insert_Element_lp(long long n, long long lp[], long long size) {
  long long hash = getHash_lp(n, lp, size);
  if (lp[hash] == -1) {
    lp[hash] = n;
  } else {
    long long temp = hash;
    while (lp[temp] != -1) {
      temp = (temp + 1) % size;
    }
    lp[temp] = n;
  }
}
long long find(long long n, long long lp[], long long size) {
  long long hash = getHash_lp(n, lp, size);
  if (lp[hash] == -1) {
    return -1;
  } else {
    long long temp = hash;
    long long flag = 0;
    long long pos = 0;
    while (lp[temp] != -1) {
      if (lp[temp] == n) {
        flag = 1;
        pos = temp;
        break;
      }
      temp = (temp + 1) % size;
    }
    if (flag == 1)
      return pos;
    else
      return -1;
  }
}
long long getHash_qp(long long n, long long qp[], long long size) {
  return n % size;
}
void Insert_Element_qp(long long n, long long qp[], long long size) {
  long long hash = getHash_lp(n, qp, size);
  if (qp[hash] == -1) {
    qp[hash] = n;
  } else {
    long long temp = hash;
    long long val = 1;
    while (qp[temp] != -1) {
      temp = (hash + val * val) % size;
      val++;
    }
    qp[temp] = n;
  }
}
long long find_qp(long long n, long long qp[], long long size) {
  long long hash = getHash_lp(n, qp, size);
  if (qp[hash] == -1) {
    return -1;
  } else {
    long long temp = hash;
    long long flag = 0;
    long long pos = 0;
    long long val = 1;
    while (qp[temp] != -1) {
      if (qp[temp] == n) {
        flag = 1;
        pos = temp;
        break;
      }
      temp = (hash + val * val) % size;
      val++;
    }
    if (flag == 1)
      return pos;
    else
      return -1;
  }
}
long long int power(int x, int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return (power(x, y / 2) * (power(x, y / 2)));
  else
    return x * (power(x, y / 2) * (power(x, y / 2)));
}
int horner(char arr[], int start, int end, long long int val, int size,
           long long int arr2[]) {
  if (val % arr2[end] == 0)
    return 1;
  else
    return 0;
}
long long int hornercalc(char arr[], int start, int end, int size) {
  long long int ans = 0;
  for (int i = start; i <= end; i++) {
    ans = (ans + (((int)arr[i]) * power(2, (int)arr[i] - 96)));
  }
  return ans;
}
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int count(char arr[], int end) {
  char arr2[100002];
  int len = strlen(arr);
  int size = 0;
  int hash1[27] = {0};
  int hash2[27] = {0};
  int ans = INT_MAX;
  for (int i = 0; i <= end; i++) {
    arr2[i] = arr[i];
  }
  for (int i = 0; i < len; i++) {
    hash1[arr[i] - 'a']++;
  }
  for (int j = 0; j <= end; j++) {
    hash2[arr2[j] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (hash2[i] != 0) {
      ans = min(ans, hash1[i] / hash2[i]);
    }
  }
  if (len == ans * (end + 1))
    return 1;
  else
    return 0;
}
int main() {
  char arr1[100002], arr2[100002];
  scanf("%s", arr1);
  scanf("%s", arr2);
  int n = strlen(arr1);
  int m = strlen(arr2);
  int len = min(n, m);
  long long int ans1 = 0;
  long long int ans2 = 0;
  long long int value[len];
  long long int value2[len];
  long long int hi = 0;
  long long int hi2 = 0;
  for (int i = 0; i < len; i++) {
    hi = (hi + (((int)arr1[i]) * pow(2, (int)arr1[i] - 96)));
    value[i] = hi;
  }
  for (int i = 0; i < len; i++) {
    hi2 = (hi2 + (((int)arr2[i]) * pow(2, (int)arr1[i] - 96)));
    value2[i] = hi2;
  }
  ans1 = hornercalc(arr1, 0, n - 1, n);
  ans2 = hornercalc(arr2, 0, m - 1, m);
  int ans = 0;
  for (int i = 0; i < len; i++) {
    if (horner(arr1, 0, i, ans1, n, value) == 1 &&
        horner(arr2, 0, i, ans1, m, value2) == 1 &&
        horner(arr1, 0, i, ans2, n, value) == 1 &&
        horner(arr2, 0, i, ans2, m, value2) == 1)
      ans++;
  }
  printf("%d\n", ans);
}
