Longest Prefix Suffix

medium
Given a string S, print the longest Prefix which is also a suffix.
Try doing it using constant space.

Input Format

A string S

Output Format

Print the answer, print "" (without quotes) if no answer found.

Constraints

2 <= |S| <= 10^5

Example

Input
abcab
Output
ab
Previous
Longest Duplicate Substring
Next
Lexicographical Suffixes

Related Questions