#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<bool> bits;
  bits.reserve(n);
  for (int i = 0; i < n; i++) {
    char bit;
    cin >> bit;
    bit -= '0';
    bits.push_back((bool)bit);
  }
  vector<int> dp(n + 1);
  dp[n] = 1;
  for (int i = n - 1; i >= 1; i--) {
    if (n % i != 0) continue;
    dp[i] = n / i;
    for (int j = 2 * i; j <= n; j += i) {
      dp[i] -= dp[j];
    }
  }
  int ans = 0;
  auto process = [&](int num) {
    bool all_work = true;
    for (int j = 0; j < num; j++) {
      bool ok = true;
      int pos = j;
      do {
        ok ^= bits[pos];
        pos += num;
        pos %= n;
      } while (pos != j);
      all_work = all_work && ok;
    }
    if (all_work) {
      ans += dp[num];
    }
  };
  for (int num = 1; num * num <= n; num++) {
    if (n % num == 0) {
      process(num);
      if (num * num != n) {
        process(n / num);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
