#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int gcd(int a, int b) { return (!b) ? (a) : (gcd(b, a % b)); }
int n;
char s[N];
int coef[N];
bool vis[N];
bool check(int d) {
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      int j = i, c = 0;
      do {
        vis[j] = true;
        c += (s[j] == '1');
        ((j -= d) < 0) && (j += n);
      } while (!vis[j]);
      if (c & 1) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    coef[gcd(i, n)]++;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (coef[i]) {
      ans += check(i) * coef[i];
    }
  }
  printf("%d\n", ans);
  return 0;
}
