import io.StdIn.readLine


object Main {
  def main(args: Array[String]): Unit = {
    val n = readLine().toInt
    val s = readLine()
    val t = readLine()

    for (i <- (0 to n).reverse) {
      if (s.slice(n - i, n) == t.slice(0, i)) {
        println(2 * n - i)
        return
      }
    }
  }
}
