#include <bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 3e5 + 7;
const int mod = 1e9 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long n;
int s[maxn];
int f[maxn];
int ans;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%1d", &s[i]);
  for (long long i = 1; i <= n; i++) {
    if (n % i == 0) {
      long long j;
      for (j = 1; j <= i; j++) {
        int tmp = 0;
        for (long long k = j; k <= n; k += i) tmp ^= s[k];
        if (tmp) break;
      }
      if (j > i) f[i] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    int k = gcd(i, n);
    ans += f[k];
  }
  printf("%d\n", ans);
  return 0;
}
