#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
string s;
bool f[N];
bool check(int d) {
  for (int k = 0; k < d; ++k) {
    int sum = 0;
    for (int i = k; i < n; i += d) sum += s[i] - '0';
    if (sum & 1) return false;
  }
  return true;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  cin >> n >> s;
  for (int x = 1; x * x <= n; ++x) {
    if (n % x) continue;
    f[x] = check(x);
    f[n / x] = check(n / x);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans += (int)f[gcd(i, n)];
  cout << ans;
}
