object Main extends App {
  @scala.annotation.tailrec
  def loop(n: Int, s: String, t: String): Int =
    if (n == 0 || s == t) n else loop(n - 1, s.tail, t.init)

  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val s, t = sc.next()
  println(N * 2 - loop(N, s, t))
}
