let levenshtein_distance (x, y) =
  if x = y then 0
  else begin
    let m = String.length x in
    let n = String.length y in
    if m = 0 then n
    else if n = 0 then m
    else begin
      let s = Array.init (n + 1) (fun i -> i) in
      let t = Array.make (n + 1) 0 in
      for i = 0 to m - 1 do
        t.(0) <- i + 1;
        for j = 0 to n - 1 do
          let c = if x.[i] = y.[j] then 0 else 1 in
          let d = 1 + (if t.(j) < s.(j+1) then t.(j) else s.(j+1)) in
          t.(j+1) <- if s.(j) + c < d then s.(j) + c else d;
        done;
        Array.iteri (fun i e -> s.(i) <- e) t;
      done;
      t.(n)
    end
  end

let () =
  Scanf.scanf "%s %s " (fun x y -> x, y)
  |> levenshtein_distance
  |> Printf.printf "%d\n"