#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, ans, res[N];
char s[N];
vector<int> p, cnt[N];
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++)
    if (n % i == 0) {
      cnt[i].resize(i);
      p.push_back(i);
    }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < p.size(); j++) {
      int x = p[j];
      if (s[i] == '1') cnt[x][i % x] ^= 1;
    }
  for (int i = 0; i < p.size(); i++) {
    int x = p[i];
    for (int j = 0; j < x; j++) res[x] |= cnt[x][j];
  }
  for (int i = 1; i <= n; i++) ans += !res[gcd(i, n)];
  printf("%d", ans);
  return 0;
}
