s=gets.chomp
r=gets.chomp

def henshu(s,r)
  return 0 if s.length==0 && r.length==0
  return s.length if r.length==0
  return r.length if s.length==0

  d=Array.new(s.length+1){Array.new(r.length+1,0)}
  (s.length+1).times do |i1|
    d[i1][0]=i1
  end
  (r.length+1).times do |i2|
    d[0][i2]=i2
  end

  (s.length).times do |i1|
    (r.length).times do |i2|
      if s[i1]==r[i2] then
        d[i1+1][i2+1]=d[i1][i2]
      else
        d[i1+1][i2+1]=[d[i1][i2],d[i1+1][i2],d[i1][i2+1]].min+1
      end
    end
  end

  return d[s.length][r.length]

end

puts henshu(s,r)