## main

while line = gets
  str0 = line.strip
  str1 = gets.strip

  if str0.length < str1.length
    tmp = str0; str0 = str1; str1 = tmp
  end

  n0 = str0.length
  n1 = str1.length

  zeros = (n1 + 1).times.map{0}

  seqs = 2.times.map{zeros.clone}

  cur = 0
  nxt = 1

  max_len = 0

  for i in (0...n0)
    seqs[nxt].fill(0)

    for j in (0...n1)
      if str0[i] == str1[j]
        l = seqs[nxt][j + 1] = seqs[cur][j] + 1
        max_len = l if max_len < l
      else
        seqs[nxt][j + 1] = 0
      end
    end

    nxt = cur
    cur = 1 - cur
  end

  puts max_len
end