#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
char str[N], f[N], sum[N];
int n, v[N];
int gcd(int a, int b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
bool ok(int k) {
  for (int i = 0; i < k; i++) {
    int num = 0;
    for (int j = i; j < n; j += k) {
      num ^= (str[j] - '0');
    }
    if (num) return 0;
  }
  return 1;
}
int main() {
  int flag = 1;
  cin >> n;
  scanf("%s", str);
  for (int k = 1; k <= n; k++) v[gcd(n, k)]++;
  int ans = 0;
  for (int k = 1; k <= n; k++) {
    if (v[k]) ans += v[k] * ok(k);
  }
  cout << ans << endl;
}
