#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200000 + 100;
int vis[maxn];
int vis2[maxn] = {0};
long long len;
bitset<maxn> b;
bool legal(long long k) {
  memset(vis, 0, maxn * sizeof(int));
  for (long long i = 0; i < len; ++i) {
    bool flag = 0;
    long long j = i;
    while (!vis[j]) {
      flag = (flag ^ b[j]);
      vis[j] = 1;
      j = ((j + k) % len);
    }
    if (flag == 1) return false;
  }
  return true;
}
long long euler[maxn];
void Init() {
  euler[1] = 1;
  for (int i = 2; i < maxn; i++) euler[i] = i;
  for (int i = 2; i < maxn; i++)
    if (euler[i] == i)
      for (int j = i; j < maxn; j += i) euler[j] = euler[j] / i * (i - 1);
}
int main() {
  Init();
  long long ans = 0;
  cin >> len >> b;
  for (int i = 1; i <= sqrt(len); ++i) {
    long long tmp1;
    long long tmp2;
    if ((len % i) == 0) {
      tmp1 = i;
      tmp2 = len / i;
      if (vis2[tmp1] == 0 && tmp1 != len) {
        if (legal(tmp1)) ans += (euler[len / tmp1]);
        vis2[tmp1] = 1;
      }
      if (vis2[tmp2] == 0 && tmp2 != len) {
        if (legal(tmp2)) ans += (euler[len / tmp2]);
        vis2[tmp2] = 1;
      }
    }
  }
  if (b.count() == 0) ans++;
  cout << ans << endl;
  return 0;
}
