s1 = gets.to_s.split("")
s2 = gets.to_s.split("")

dp = Array.new(s1.size){Array.new(s2.size, 0)}
for i in 0..s1.size-1 do
    dp[i][0] = i
end
for i in 0..s2.size-1 do
    dp[0][i] = i
end
for i in 0..s1.size-2 do
    for j in 0..s2.size-2 do
        if s1[i] == s2[j] then
            dp[i+1][j+1] = dp[i][j]
        else
            dp[i+1][j+1] = [dp[i][j],dp[i+1][j],dp[i][j+1]].min + 1
        end
    end
end
puts dp[s1.size - 1][s2.size - 1]