#include <bits/stdc++.h>
using namespace std;
long long powmod(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    exponent /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
const int upperlimit = 1e6 + 1;
const int mod = 1e9 + 7;
bool temp[upperlimit];
int main() {
  int no1 = 0, n;
  bool check;
  string s;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    if (n % i) continue;
    check = true;
    for (int j = 0; j < i; j++) {
      no1 = 0;
      for (int k = j; k < n; k += i) {
        if (s[k] == '1') no1++;
      }
      if (no1 & 1) check = false;
    }
    if (check) temp[i] = true;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) ans += temp[gcd(n, i)];
  printf("%d", ans);
  return 0;
}
