#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
int n, F[N];
char A[N];
vector<int> vec[N];
int main() {
  scanf("%d%s", &n, A);
  int cnt = 0;
  for (int i = 0; i < n; i++) cnt += (A[i] == '1');
  if (!cnt) return !printf("%d\n", n);
  for (int d = 1; d < n; d++)
    if (n % d == 0) {
      bool fail = 0;
      for (int j = 0; j < d; j++) {
        int cnt = 0;
        for (int i = j; i < n; i += d) cnt ^= (A[i] == '1');
        if (cnt) fail = 1;
      }
      for (int i = d; i < n; i += d) F[i] = fail;
    }
  cnt = 0;
  for (int i = 1; i < n; i++)
    if (F[i] == 0) cnt++;
  return !printf("%d\n", cnt);
}
