#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) a[i] = (s[i] == '1');
  if (s == string(n, '0')) {
    cout << n << endl;
    return 0;
  }
  vector<int> d(n);
  set<int> st;
  for (int x = 1; x <= n - 1; ++x) {
    d[x] = gcd(x, n);
    st.insert(d[x]);
  }
  map<int, int> mp;
  for (int x : st) {
    bool ok = true;
    for (int i = 0; i < x; ++i) {
      int cnt = 0;
      for (int j = 0; j < n / x; ++j) cnt += a[i + j * x];
      if (cnt % 2) ok = false;
    }
    mp[x] = ok;
  }
  int ans = 0;
  for (int x = 1; x <= n - 1; ++x) ans += mp[d[x]];
  cout << ans << endl;
  return 0;
}
