Under construction

Still being built. Things may change

Cave Paintings

Time limit1sMemory limit1024 MB

Summary
Given a string s, find the length of the longest palindrome that is a substring of some cyclic shift of s.
Level

Medium6 of 10

Topics
String, String matching
Solved
No attempts yet

Problem

Doctor Braveston and his group found an ancient cave in Jumanji. A string ss of lowercase Latin letters was written on its wall. To continue, the explorers must find the length of the longest palindrome that is a substring of some cyclic shift of ss.

A palindrome is a string that reads the same forward and backward. For example, abacaba, abba, and q are palindromes. A substring is a contiguous run of characters from a string. A cyclic shift is formed by cutting a prefix from the string and appending it to the end. For example, bacabaa, cabaaba, and abacaba are cyclic shifts of abacaba.

Input

The input is a single non-empty line containing the string ss. The string consists of lowercase Latin letters only, and its length does not exceed 10610^6.

Output

Print one integer, the maximum length of a palindrome that is a substring of some cyclic shift of ss.

Examples1

  1. Example 1

    Input
    babaca
    
    Expected output
    5