string = gets.strip
text = gets.strip

min_diff = text.size

(string.size - text.size + 1).times.each do |index|
  break if index + text.size > string.size
  break if min_diff.zero?

  diff = text.size
  substr = string[index...(index + text.size)]
  substr.size.times.each do |i|
    diff -= 1 if substr[i] == text[i]
  end
  min_diff = [min_diff, diff].min
end

puts min_diff