#include <bits/stdc++.h>
using namespace std;
namespace star {
const int maxn = 2e5 + 10;
int n, a[maxn], but[maxn];
inline bool check(int k) {
  bool ok = true;
  for (int b = 1; b <= k and ok; b++) {
    int sum = 0;
    for (int j = b; j <= n; j += k) sum += a[j];
    if (sum & 1) ok = false;
  }
  return ok;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline void work() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%1d", &a[i]);
  for (int i = 1; i <= n; i++) ++but[gcd(i, n)];
  int ans = 0;
  for (int k = 1; k * k <= n; k++) {
    if (n % k == 0) ans += but[k] * check(k);
    if (k * k != n) ans += but[n / k] * check(n / k);
  }
  printf("%d\n", ans);
}
}  // namespace star
signed main() {
  star::work();
  return 0;
}
