#include <bits/stdc++.h>
using namespace std;
int b[200001], a[200001];
int init(int n) {
  int t = 1;
  a[1] = 1;
  for (int x = 2; x <= sqrt(n); x++)
    if (n % x == 0) t++, a[t] = x, t++, a[t] = n / x;
  for (int x = 1; x < n; x++) b[x] = 1;
  return t;
}
int gcd(int x, int y) {
  if (x == 0) return y;
  if (y == 0) return x;
  if (x > y)
    return gcd(x % y, y);
  else
    return gcd(x, y % x);
}
int main() {
  int n;
  cin >> n;
  int t = init(n);
  string ch;
  cin >> ch;
  for (int x = 1; x <= t; x++)
    for (int y = 0; y < a[x]; y++) {
      long long sum = 0;
      for (int z = y; z < n; z += a[x]) sum += ch[z];
      if (sum % 2 != 0) {
        b[a[x]] = 0;
        break;
      }
    }
  int ans = 1;
  bool bo = true;
  if (bo && ch[0] != '0') ans = 0, bo = false;
  for (int x = 1; x < n; x++)
    if (bo && ch[x] != '0')
      ans += b[gcd(x, n)] - 1, bo = false;
    else
      ans += b[gcd(x, n)];
  cout << ans << endl;
}
