$s1 = gets.chomp.split('')
$s2 = gets.chomp.split('')

s1_length = $s1.length

s2_length = $s2.length

$table = Array.new(s1_length + 1).map { Array.new(s2_length + 1, 0) }

def max(a, b)
  a < b ? b : a
end

s1_length.times do |i|
  s2_length.times do |j|
    $table[i + 1][j + 1] = if s1_length[i] == s2_length[j]
                             $table[i][j] + 1
                           else
                             max($table[i + 1][j], $table[i][j + 1])
                          end
  end
end

common = $table.last.last

puts max(s1_length, s2_length) - common

