S = list(input()) S = list(map(ord, S)) N = len(S) inf = 10 ** 18 dp = [inf] * (N + 1) mod = 2**31 - 1 bb = [1] * (N + 2) invbb = [1] * (N + 2) for i in range(1, N + 2): bb[i] = bb[i - 1] * 4869 % mod invbb[i] = pow(bb[i], mod - 2, mod) b = 4869 invb = pow(b, mod - 2, mod) SS = [0] for i in range(1, N + 1): val = 0 rh = SS[i - 1] * b + S[i - 1] SS.append(rh%mod) pre = 0 for j in range(i): rh2 = pre * b + S[i - j - 1] rh2 %= mod if rh2 == (rh - SS[i - j - 1] * bb[j + 1]) % mod: val = max(val, min(dp[i - j - 1], j + 1)) pre = rh2 dp[i] = val print(dp[-1])