Programmer's school

Forgot password?
[problems] [status] [courses] [info] [register]
Login:   Password:    

Suffixes

(Time limit: 1 sec. Memory limit: 16 MB Difficulty: 45%)

Let the string be a sequence of lowercase letters of the English alphabet. For example, empty sequence "" is a string, the word "aabaf" or an infinite sequence of letters "a" are strings too.

The i-th suffix Si of the string S is the string S from which the first i letters are cut: so, for the string S = “aabaf” the suffixes will be:

S0 = “aabaf”

S1 = “abaf”

S2 = “baf”

S3 = “af”

S4 = “f”

S5 = S6 = S7 = . . . = “”

The suffixes are defined for all i > 0.

The cyclic extension S* of a finite string S is a string obtained by appending it to itself an infinite number of times. So,

S* = S0* = “aabafaabafaa...”

S1* = “abafabafabaf...”

S2* = “bafbafbafbaf...”

S3* = “afafafafafaf...”

S4* = “ffffffffffff...”

S5* = S6* = S7*= . . . = “”

For a given string S, find out how many of its suffixes Si have the same cyclic extension as the string S itself that is the number of different i such that S*= Si*.

Input

Input contains a string S consisting of 1 to 105 lowercase letters of the English alphabet.

Output

Output the number of suffixes of the string S having the same cyclic extension as itself.

Samples

¹INPUT.TXTOUTPUT.TXT
1aa2
2ab1
3qqqq4
4xyzzyxy1

Äëÿ îòïðàâêè ðåøåíèÿ çàäà÷è íåîáõîäèìî çàðåãèñòðèðîâàòüñÿ è àâòîðèçîâàòüñÿ!


 C++ programming language
 Solution of olympiad tasks
 Regional competition
 Books by Fyodor Menshikov
 USE in informatics
 Training olympics
 Introduction
 Integer arithmetic
 Sorting algorithms
 Long arithmetic
 C++ Standard Template Library
 Dynamic programming
 Combinatorics
 Computational geometry
 String
 Data structures
 Graph theory - 1
 Graph theory - 2
 Simple tasks
 Algorithms on strings
 Polynomial hash
 A. Antipalindrom
 B. Prefiks-funktsiya
 C. Z-funktsiya
 D. Pole chudes
 E. Poisk podstroki
 F. Sdvig teksta
 G. Tsiklicheskaya stroka
 H. Suffiksy
 I. Kolichestvo razlichnyh podstrok
 J. Dendrohronologiya
 K. Abracadabra
 L. Algoritm Manakera

Krasnoyarsk regional Palace of pioneers, (c)2006 - 2025, ÈÍÍ 246305493507, E-mail: admin@acmp.ru