#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int solve() {
  long long int n, i, j, k, m, x;
  string s;
  cin >> n >> s;
  vector<int> pos(n + 1);
  long long int ans = 0;
  for (i = 1; i * i <= n; ++i) {
    if (n % i) continue;
    long long int d = i;
    int f = 1;
    int p;
    for (j = 0; j < i; ++j) {
      p = 0;
      k = j;
      while (k < n) p ^= (s[k] - '0'), k += i;
      if (p) f = 0;
    }
    if (f) pos[i] = 1;
    f = 1;
    d = n / i;
    for (j = 0; j < d; ++j) {
      p = 0;
      k = j;
      while (k < n) p ^= (s[k] - '0'), k += d;
      if (p) f = 0;
    }
    if (f) pos[d] = 1;
  }
  for (i = 1; i <= n; ++i) {
    long long int g = gcd(n, i);
    ans += pos[g];
  }
  cout << ans << "\n";
  return 0;
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
  ;
}
