#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
int a[N], n;
bool vis[N];
string s;
void calc(int k) {
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < k; i++) {
    int val = 0;
    for (int j = i;; j = (j + k) % n) {
      if (vis[j]) break;
      vis[j] = 1;
      val ^= s[j] - '0';
    }
    if (val) return;
  }
  a[k] = 1;
}
int main() {
  scanf("%d", &n);
  cin >> s;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) calc(i);
    ans += a[gcd(n, i)];
  }
  printf("%d\n", ans);
}
