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

let () =
  let s1 = read_line () in
  let s2 = read_line () in
  Printf.printf "%d\n" (levenshtein_distance s1 s2)