s1,s2 = [gets,gets].map(&:chomp).sort_by(&:size)

s1 += ' '*(s2.size-s1.size)

dp = Array.new(s1.size+1){Array.new(s2.size+1,0)}

1.upto(s1.size) do |y|
  1.upto(s2.size) do |x|
    if s2[y] == s1[x]
      dp[y][x] = dp[y-1][x-1]
    else
      dp[y][x] = [dp[y-1][x], dp[y][x-1], dp[y-1][x-1]].min + 1
    end
  end
end

puts dp[s1.size][s2.size]