#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = 1ll << 62;
const int mods = 1e9 + 7;
const int MAXN = 200005;
const int INF = 0x3f3f3f3f;
inline int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
char st[MAXN];
int f[MAXN], n, ans = 0;
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int check(int x) {
  for (int i = 1; i <= x; i++) {
    int num = 0;
    for (int j = i; j <= n; j += x) num += (st[j] == '1');
    if (num & 1) return 0;
  }
  return 1;
}
signed main() {
  n = read();
  scanf("%s", st + 1);
  for (int i = 1; i <= n; i++) f[gcd(n, i)]++;
  for (int i = 1; i <= n; i++)
    if (n % i == 0 && check(i)) ans += f[i];
  printf("%d\n", ans);
  return 0;
}
