s = gets.chomp
t = gets.chomp

kotae = 0

while t.size > 1 do
 if s.include?(t) == true
      break
 else
   t = t.chop!
   kotae += 1
 end
end

if kotae.size == t.size
  puts kotae -1
else
  puts kotae
end