import java.util.Scanner

object Main extends App { 
  val sc = new Scanner(System.in)
  val S1, S2 = sc.nextLine()

  class DP(s0:String, s1:String) {
    val a0 = ("*"+s0).toCharArray
    val a1 = ("*"+s1).toCharArray
    val hight = a0.length
    val width = a1.length
    val memo = Array.ofDim[Int](hight, width)
    for (i <- 0 until hight) memo(i)(0) = i
    for (j <- 0 until width) memo(0)(j) = j

    def solver():Int = {
      for (i <- 1 until hight; j <- 1 until width) {
        val ci = memo(i-1)(j)+1
        val cd = memo(i)(j-1)+1
        val cr = memo(i-1)(j-1) + (if (a0(i) == a1(j)) 0 else 1)
        memo(i)(j) = List(ci,cd,cr).min
      }
      memo(hight-1)(width-1)      
    }
  }

  val dp = new DP(S1, S2)

  println(dp.solver())
}
