def string_diff(a,b)
  num = 0
  a.size.times do |i|
    num += 1 if a[i] != b[i]
  end
  num
end

s = gets.chomp
t = gets.chomp
if s.include?(t)
  puts '0'
  exit
end
ans = t.size
t.split('').each_with_index do |u, i|
  start = i
  finish = s.size - (t.size - i)
  target = s[start..finish]
  next unless target.include?(u)

  (start..finish).each do |j|
    next unless s[j] == t[i]

    num = string_diff(s[j...j+t.length], t[i..-1])
    ans = [ans, num + i].min
  end
end
puts ans
