#include <bits/stdc++.h>
using namespace std;
char s[200010];
int n;
const int maxn = 200000 + 10;
int m[maxn], phi[maxn], p[maxn], pt;
void make() {
  phi[1] = 1;
  int N = maxn;
  int k;
  phi[1] = 1;
  for (int i = 2; i < N; i++) {
    if (!m[i]) p[pt++] = m[i] = i, phi[i] = i - 1;
    for (int j = 0; j < pt && (k = p[j] * i) < N; j++) {
      m[k] = p[j];
      if (m[i] == p[j]) {
        phi[k] = phi[i] * p[j];
        break;
      } else
        phi[k] = phi[i] * (p[j] - 1);
    }
  }
}
int nxt(int now, int x, int n) {
  if (now + x <= n)
    return now + x;
  else
    return now + x - n;
}
long long solve(long long x) {
  if (x == n) return 0;
  for (int i = 1; i <= x; i++) {
    int tot = 0;
    int now = i;
    while (1) {
      if (s[now] == '1') tot++;
      now = nxt(now, x, n);
      if (now == i) break;
    }
    if (tot % 2 == 1) return 0;
  }
  return phi[n / x];
}
int main() {
  cin >> n;
  make();
  scanf("%s", s + 1);
  bool fff = false;
  for (int i = 1; i <= n; i++)
    if (s[i] == '1') fff = true;
  if (fff == false) {
    cout << n << endl;
    return 0;
  }
  long long ans = 0;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i) continue;
    ans += solve(i);
    if (n / i == i) continue;
    ans += solve(n / i);
  }
  cout << ans << endl;
  return 0;
}
