#include <bits/stdc++.h>
using namespace std;
int n, cnt;
int ans[5500];
char c[5500][5500], x[5500][5500];
string num[20] = {"0000", "0001", "0010", "0011", "0100", "0101",
                  "0110", "0111", "1000", "1001", "1010", "1011",
                  "1100", "1101", "1110", "1111"};
int chu(int i, int x) { return i % x ? i / x + 1 : i / x; }
bool judge(int x) {
  bool flag = true;
  for (int i = 1; i <= n && flag; i++)
    for (int j = 1; j <= n && flag; j++)
      if (c[i][j] != c[(chu(i, x) - 1) * x + 1][(chu(j, x) - 1) * x + 1])
        flag = false;
  return flag;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    if (n % i == 0) ans[++cnt] = i;
  printf("%d", cnt);
  return 0;
  for (int i = 1; i <= n; i++) {
    scanf("\n");
    for (int j = 1; j <= n / 4; j++) scanf("%c", &x[i][j]);
  }
  for (int i = 1; i <= n; i++) {
    int tot = 0;
    for (int j = 1; j <= n / 4; j++) {
      int now;
      if (x[i][j] >= '0' && x[i][j] <= '9')
        now = x[i][j] - '0';
      else
        now = x[i][j] - 55;
      for (int k = 0; k < 4; k++) c[i][++tot] = num[now][k];
    }
  }
  int head = 1;
  int tail = cnt;
  int mid;
  while (head <= tail) {
    mid = (head + tail) >> 1;
    if (judge(ans[mid]))
      head = mid;
    else
      tail = mid;
  }
  printf("%d", ans[mid]);
  return 0;
}
