let solve n (s:string) (t:string) =
    if s.Length + t.Length <= n then n
    elif s = t && n <= s.Length then s.Length
    else
        let sameLen = seq s |> Seq.rev |> Seq.zip (seq t) |> Seq.takeWhile (fun (s, t) -> s = t) |> Seq.length
        s.Length + t.Length - sameLen



let () =
  let n = stdin.ReadLine () |> int
  let s = stdin.ReadLine ()
  let t = stdin.ReadLine ()

  solve n s t |> printfn "%d"