Under construction

Still being built. Things may change

Periodic Strings

Interview

Time limit2sMemory limit512 MB

Summary
Given a string, find the smallest k such that cutting it into blocks of length k makes each block a one-step rotation of the previous block.
Level

Medium4 of 10

Topics
String, Brute force, Implementation, Math
Solved
No attempts yet

Problem

Define a kk-periodic string as follows.

A string ss is kk-periodic if its length ∣s∣|s| is a multiple of kk and, when you cut ss into ∣s∣/k|s|/k pieces of length kk, every piece except the first equals the previous piece with its last character moved to the front.

For example, abccabbcaabc is 33-periodic. It cuts into abc, cab, bca, abc, and every piece except the first is the previous piece rotated by one character (abc →\rightarrow cab, cab →\rightarrow bca, bca →\rightarrow abc).

Given a string ss, find the smallest kk for which ss is kk-periodic.

Input

The first line contains a string ss consisting only of lower-case letters (1≤∣s∣≤1001 \leq |s| \leq 100).

Output

Print, on a single line, the smallest kk for which the input string is kk-periodic.

Examples4

  1. Example 1

    Input
    aaaaaaaa
    
    Expected output
    1
    
  2. Example 2

    Input
    abbaabbaabba
    
    Expected output
    2
    
  3. Example 3

    Input
    abcdef
    
    Expected output
    6
    
  4. Example 4

    Input
    abccabbcaabc
    
    Expected output
    3