
def make2d(m,n)
  Array.new(m).map{Array.new(n,0)}
end


def min(x,y)
  if x > y
    return y
  else
    return x
  end
end

def align_ed(s,t)
  m = s.length()
  n = t.length()
  a = make2d(m+1,n+1)
  a[0][0] = 0
  for j in 1..n
    a[0][j] = a[0][j-1] + 1
  end
  for i in 1..m
    a[i][0] = a[i-1][0] + 1
  end
  for i in 1..m 
    for j in 1..n
      x = a[i-1][j-1]
      if s[i-1] != t[j-1]
        x += 1
      end
      y = a[i][j-1] + 1                         
      z = a[i-1][j] + 1
      a[i][j] = min(x,min(y,z))
    end
  end
  a[-1][-1]
end


s1 = gets.chomp
s2 = gets.chomp
puts align_ed(s1,s2)