#P1184A2. Heidi Learns Hashing (Medium)

    ID: 4825 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>brute forcenumber theory*2100

Heidi Learns Hashing (Medium)

No submission language available for this problem.

Description

After learning about polynomial hashing, Heidi decided to learn about shift-xor hashing. In particular, she came across this interesting problem.

Given a bitstring y{0,1}ny \in \{0,1\}^n find out the number of different kk (0k<n0 \leq k < n) such that there exists x{0,1}nx \in \{0,1\}^n for which $y = x \oplus \mbox{shift}^k(x).$

In the above, \oplus is the xor operation and $\mbox{shift}^k$ is the operation of shifting a bitstring cyclically to the right kk times. For example, 001111=110001 \oplus 111 = 110 and $\mbox{shift}^3(00010010111000) = 00000010010111$.

The first line contains an integer nn (1n21051 \leq n \leq 2 \cdot 10^5), the length of the bitstring yy.

The second line contains the bitstring yy.

Output a single integer: the number of suitable values of kk.

Input

The first line contains an integer nn (1n21051 \leq n \leq 2 \cdot 10^5), the length of the bitstring yy.

The second line contains the bitstring yy.

Output

Output a single integer: the number of suitable values of kk.

Samples

Sample Input 1

4
1010

Sample Output 1

3

Note

In the first example:

  • $1100\oplus \mbox{shift}^1(1100) = 1010$
  • $1000\oplus \mbox{shift}^2(1000) = 1010$
  • $0110\oplus \mbox{shift}^3(0110) = 1010$

There is no xx such that xx=1010x \oplus x = 1010, hence the answer is 33.