#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  string s;
  cin >> N >> s;
  map<int, bool> mem;
  int ans = (s == string(N, '0'));
  for (int k = 1; k < N; ++k) {
    int g = gcd(k, N);
    if (mem.find(g) != mem.end()) {
      bool res = mem[g];
      if (res) ans++;
      continue;
    }
    vector<int> freq(g, 0);
    for (int i = 0; i < N; ++i) {
      if (s[i] == '1') {
        freq[i % g]++;
      }
    }
    bool good = true;
    for (int i = 0; i < g; ++i) {
      if (freq[i] % 2 == 1) {
        good = false;
        break;
      }
    }
    mem[g] = good;
    if (good) ans++;
  }
  cout << ans << endl;
  return 0;
}
