#include <bits/stdc++.h>
using pii = std::pair<int, int>;
using vii = std::vector<pii>;
using vi = std::vector<int>;
using ll = long long;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  ::std::ios::sync_with_stdio(false);
  ::std::cin.tie(0);
  int n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  std::vector<int> mem(n + 1, -1);
  std::vector<int> arr(n);
  for (int i = 0; i < n; ++i) arr[i] = s[i] - '0';
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int d = gcd(i, n);
    if (mem[d] >= 0) {
      ans += mem[d];
      continue;
    }
    int cur = 1;
    for (int j = 0; j < d; ++j) {
      int xor_sum = 0;
      for (int k = j; k < n; k += d) {
        xor_sum ^= arr[k];
      }
      if (xor_sum == 1) {
        cur = 0;
        break;
      }
    }
    mem[d] = cur;
    ans += cur;
  }
  std::cout << ans << std::endl;
}
