#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}
const int N = 2e5 + 11;
int n, sta, vis[N];
char a[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> a + 1;
  for (int i = 1; i <= n; i++)
    if (a[i] == '1') sta = 1;
  if (!sta) return cout << n << '\n', 0;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      int sta = 1;
      for (int j = 1; j <= i; j++) {
        int res = 0;
        for (int k = j; k <= n; k += i) {
          res ^= (a[k] - '0');
        }
        sta &= !res;
      }
      vis[i] = sta;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += vis[gcd(i, n)];
  }
  cout << ans << endl;
  return 0;
}
