Iron String

0

0 votes
Medium
Problem

Iron Man is the macho man of Avengers. All Avengers team are struggling to find a iron number N from an iron string S.  As Iron man has lots of IQ in the field of technology among all avengers but even he is struggling to solve the problem. So you can help him to solve this iron string.

Iron number is defined from iron string i.e. lets say K is the substring of S then N=MAX of (|K|*Number of times K occurs in S) for all such substring in S.

Input

A single line of input containing string S.

Output

Print N as sum of all such substring K from S.

Constraints

1<=|S|<=105

Author - Vaibhaw Rai

Sample Input
aaaaaa
Sample Output
12
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

‘a’  = 6

‘aa’ = 10

‘aaa’ = 12

‘aaaa’=12

‘aaaaa’=10

‘aaaaaa’=6

Max of all is 12.

Contributers:
Editor Image

?