s = gets.chomp.split("")
t = gets.chomp.split("")

t.push("-")
maxln = 0
for st in 0..(t.length-1)
  id = -1
  len = 0
  for i in st..(s.length-1-(t.length-st))
    if id == -1 && t[st] == s[i]
      id = 1
      len = 1
    elsif id > 0
      if t[st+id] == s[i]
        id += 1
        len += 1
      else
        maxln = [maxln,len].max
        id = -1
        len = 0
      end
    end
  end
  maxln = [maxln,len].max
end
puts t.length - 1 - maxln