Alice is writing down a secret password as she hears it. The sender reads the password a second time, so she keeps writing to check her copy for mistakes. She gets one letter wrong, and her attention slips for a moment, so she misses the end of the stream. Now she cannot tell where the second reading begins.
You are given a string S[0…n−1] of lowercase English letters. Find the earliest position where the repeat of the password can start. Formally, find the index i that satisfies all of the following conditions:
- 2n≤i<n
- S[i…n−1] and S[0…n−i−1] differ in exactly one position
- among all indices satisfying the two conditions above, i is the smallest