#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  string s;
  cin >> n;
  cin >> s;
  s = " " + s;
  vector<int> cnt(n + 1, 0);
  for (int i = 1; i <= n; ++i) ++cnt[gcd(i, n)];
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (n % i) continue;
    vector<int> check(i + 1, 0);
    for (int j = 1; j <= n; ++j) check[j % i] ^= (s[j] == '1');
    bool good = true;
    for (int j = 0; j < i; ++j)
      if (check[j]) good = false;
    if (good) ans += cnt[i];
  }
  cout << ans << "\n";
  return 0;
}
