let levenshtein_distance s t =
  let m = String.length s in
  let n = String.length t in
  let d = Array.make_matrix (m + 1) (n + 1) 0 in
  for i = 1 to m do
    d.(i).(0) <- i
  done;
  for j = 1 to n do
    d.(0).(j) <- j
  done;
  for j = 1 to n do
    for i = 1 to m do
      let c = if s.[i-1] = t.[j-1] then 0 else 1 in
      d.(i).(j) <- if d.(i-1).(j) + 1 < d.(i).(j-1) + 1 then d.(i-1).(j) + 1 else d.(i).(j-1) + 1;
      d.(i).(j) <- if d.(i-1).(j-1) + c < d.(i).(j) then d.(i-1).(j-1) + c else d.(i).(j)
    done
  done;
  d.(m).(n)

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