a,b = gets,gets
dp = Array.new(a.size){Array.new(b.size,0)}
(a.size).times { |i| dp[i][0]=i }
(b.size).times { |i| dp[0][i]=i }
(a.size-1).times { |i|
	(b.size-1).times{ |j|
		dp[i+1][j+1] = (a[i]==b[j]?dp[i][j]:[dp[i][j],dp[i+1][j],dp[i][j+1]].min+1)
	}
}
puts dp[a.size-1][b.size-1]