object Main {

  def num(s: String, t: String): Int = {
    (s zip t).takeWhile { x => x._1 == x._2 }.length
  }

  def solver(s: String, t: String, n: Int): Int = {
    val ml = (s == t) match {
      case x if x == true => s.length
      case _ => (s.length + t.length) - num(s.reverse, t)
    }
    return if (ml >= n) ml else n
  }

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

    println(solver(s, t, n))
  }
}