let id x = x
module XString = struct
  let to_list str =
    let rec loop i limit =
      if i = limit then []
      else (String.get str i) :: (loop (i + 1) limit)
    in loop 0 (String.length str)

  let of_list s =
    let rec loop s n =
      match s with
        [] -> String.make n '?'
      | car :: cdr ->
         let result = loop cdr (n + 1) in
         Bytes.set result n car;
         result
    in
    Bytes.to_string (loop s 0)
  let rev s =
    of_list (List.rev (to_list s))
end

let f n s t =
  let len = ref 0 in
  for i = 1 to n do
    let s_sub = String.sub s (n - i) i in
    let t_sub = String.sub t 0 i in
    if s_sub = t_sub
    then len := i
  done;
  n + (n - !len)

let main () =
  let n = Scanf.scanf "%d\n" id in
  let s = Scanf.scanf "%s\n" id in
  let t = Scanf.scanf "%s\n" id in
  Printf.printf "%d\n" (f n s t)

let () = main ()
