#include <bits/stdc++.h>
using namespace std;
map<string, int> M;
void solve(string s) {
  int n = s.length();
  string s1;
  vector<int> facts;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      facts.push_back(i);
      if (n / i != i) facts.push_back(n / i);
    }
  }
  sort(facts.begin(), facts.end());
  for (auto l : facts) {
    if (n % l == 0) {
      s1 = s.substr(0, l);
      int f = 1;
      for (int i = l; i < n; i += l) {
        if (s1 != s.substr(i, l)) {
          f = 0;
          break;
        }
      }
      if (f) M[s1]++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s1, s2;
  cin >> s1 >> s2;
  solve(s1);
  solve(s2);
  int ans = 0;
  for (auto x : M)
    if (x.second > 1) ans++;
  cout << ans << '\n';
}
