import sys input = sys.stdin.readline def z_algo(s): c = 0 n = len(s) z = [0]*n for i in range(1, n): l = i-c if i+z[l]') s = ''.join(l) z = z_algo(''.join([S, s, s])) ans = N+10 for i in range(N-1, 2*N-1): if z[i]>=N-1: ans = min(ans, i-N+1) if ans==N+10: print(-1) else: print(ans)