def distance(str1, str2)
  str1, str2 = str1.split(//).unshift(0), str2.split(//).unshift(0)
  arr = Array.new(str1.size){Array.new(str2.size)}
  for i in 0...str2.size
    arr[0][i] = i
  end
  for i in 1...str1.size
    arr[i][0] = i
    for j in 1...str2.size
      if str1[i] == str2[j]
        arr[i][j] = [arr[i - 1][j - 1], arr[i - 1][j] + 1, arr[i][j - 1] + 1].min
      else
        arr[i][j] = [arr[i - 1][j - 1] + 1, arr[i - 1][j] + 1, arr[i][j - 1] + 1].min
      end
    end
  end
  puts arr.last.last
end
def main(input = $stdin)
  distance(input.gets.chomp, input.gets.chomp)
end
main