## main

while line = gets
  chars0 = line.strip.chars.to_a
  chars1 = gets.strip.chars.to_a

  if chars0.length > chars1.length
    tmp = chars0; chars0 = chars1; chars1 = tmp
  end

  n0 = chars0.length
  n1 = chars1.length

  chpos = Hash.new([])

  for i in (0...n1)
    ch = chars1[i]
    chpos[ch] += [i]
  end
  #p chpos

  max_len = 0

  for i in (0...n0)
    break if i + max_len > n0
    for j in chpos[chars0[i]]
      next if j + max_len > n1
      len = 1
      while i + len < n0 && j + len < n1 && chars0[i + len] == chars1[j + len]
        len += 1
      end

      max_len = len if max_len < len
    end
  end

  puts max_len
end