#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << " , ";
  err(++it, args...);
}
auto TIMESTART = chrono::steady_clock::now();
auto TIMESTOP = chrono::steady_clock::now();
void TimeStop() {
  TIMESTOP = chrono::steady_clock::now();
  auto ElapsedTime = TIMESTOP - TIMESTART;
  cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count()
       << " seconds.\n";
}
namespace fastIO {
bool IOerror = 0;
static char obuf[2000000], *OUT = obuf;
inline char nc() {
  static char buf[2000000], *p1 = buf + 2000000, *pend = buf + 2000000;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 2000000, stdin);
    if (pend == p1) {
      IOerror = 1;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void read(int& x) {
  char ch;
  while (blank(ch = nc()))
    ;
  if (IOerror) return;
  for (x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0')
    ;
}
inline void read(long long& x) {
  char ch;
  while (blank(ch = nc()))
    ;
  if (IOerror) return;
  for (x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0')
    ;
}
void print(const int& x) {
  if (x > 9) print(x / 10);
  *OUT++ = x % 10 + '0';
}
void print(const long long& x) {
  if (x > 9) print(x / 10);
  *OUT++ = x % 10 + '0';
}
void print() { fwrite(obuf, OUT - obuf, 1, stdout); }
}  // namespace fastIO
using namespace fastIO;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
long long qp(long long b, long long n, const long long mod = ::mod) {
  long long r = 1;
  if (n < 0) n += mod - 1;
  b %= mod;
  for (; n; n >>= 1, b = 1LL * (b) * (b) % mod)
    if (n & 1) r = 1LL * (r) * (b) % mod;
  return r;
}
const int maxn = 1e6 + 7;
int isp[maxn], p[maxn], phi[maxn];
void init() {
  int cnt = 0;
  phi[1] = 1;
  for (int i = 2; i < maxn; ++i) {
    if (isp[i] == 0) p[cnt++] = i, phi[i] = i - 1;
    for (int j = 0; j < cnt && 1LL * i * p[j] < maxn; ++j) {
      int tmp = i * p[j];
      isp[tmp] = 1;
      if (i % p[j] == 0) {
        phi[tmp] = phi[i] * p[j];
        break;
      }
      phi[tmp] = phi[i] * (p[j] - 1);
    }
  }
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> f;
  int tmpn = n;
  init();
  for (int i = 1; i <= tmpn; ++i) {
    if (tmpn % i) continue;
    f.push_back(i);
  }
  int ans = 0;
  for (int i = 0; i < (int)(f.size()); ++i) {
    int now = f[i], ok = 1;
    for (int j = 0; j < now; ++j) {
      int cnt = 0;
      for (int k = j; k < n; k += now) cnt += s[k] - '0';
      if (cnt % 2) ok = 0;
    }
    if (ok) ans += phi[n / now];
  }
  cout << ans << endl;
}
