import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val s = sc.next
  val t = sc.next


  val duplicate = (1 to n).find{ i =>s.substring(n - i) == t.substring(0,i)}.getOrElse(0)

  val res = n + n - duplicate

  println(res)

}
