#include <bits/stdc++.h>
const int MAXN = 2e5 + 5;
int n;
int seq[MAXN];
bool gs[MAXN];
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void SetGS() {
  for (int i = 1; i * i <= n; i++) {
    if (n % i != 0) continue;
    int x = i;
    gs[x] = 1;
    for (int j = 1; j <= x; j += 1) {
      int tot = 0;
      for (int k = j; k <= n; k += x) tot += seq[k];
      if (tot % 2) gs[x] = false;
    }
    if (i == n / i) break;
    x = n / i, gs[x] = 1;
    for (int j = 1; j <= x; j += 1) {
      int tot = 0;
      for (int k = j; k <= n; k += x) tot += seq[k];
      if (tot % 2) gs[x] = false;
    }
  }
}
int main(int argc, char *argv[]) {
  int ans = 0;
  bool allzero = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%1d", seq + i);
    if (seq[i] != 0) allzero = 0;
  }
  SetGS();
  if (allzero) ans++;
  for (int k = 1; k < n; k++) {
    int g = gcd(k, n);
    if (gs[g]) ans++;
  }
  printf("%d", ans);
  return 0;
}
