#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string str;
  cin >> str;
  map<int, int> counts;
  for (int i = 0; i < n; ++i) {
    ++counts[gcd(i, n)];
  }
  int res = 0;
  for (auto pr : counts) {
    bool works = true;
    for (int i = 0; works && i < pr.first; ++i) {
      int j = i;
      do {
        works ^= (str[j] == '1');
        j = (j + pr.first) % n;
      } while (j != i);
    }
    if (works) res += pr.second;
  }
  cout << res << '\n';
}
