gets
S = gets.chomp
h = {}
L = (S.size+1) / 2
m = 0
0.upto(S.size-1) {|i|
  j = [0,i-L].max
  j.upto(i) { |j|
    break  if i-j < m
    s = S[j..i]
    x = h[s] || [0]
    if m < x[0] && j > x[1]
      m = i-j
    else
      h[s] = [i-j,i]
    end
  }
}
if m == 0
  h = {}
  S.chars.each {|e| h[e]=0}
  m = 1  if h.keys.size < S.size
else
  m += 1
end
p m