#K14391. Smallest Repeating Substring

    ID: 24124 Type: Default 1000ms 256MiB

Smallest Repeating Substring

Smallest Repeating Substring

You are given a string \(T\). Your task is to determine whether the string can be formed by repeating one of its substrings. If it is possible, output the length of the smallest such substring; otherwise, output \(-1\). For example, if \(T = "abab"\), then it can be constructed by repeating "ab" twice, so the answer is 2.

Input Constraints: The input consists of a single non-empty string \(T\) composed of lowercase English letters.

Example:

Input: abab
Output: 2

Note: The solution must read from standard input and print the result to standard output.

inputFormat

Standard input contains a single line with the string \(T\).

outputFormat

Output a single integer: the length of the smallest substring that, when repeated, forms \(T\). If no such substring exists, output \(-1\).

## sample
abab
2