fun main(args: Array<String>) {
    agc006a()
}

fun agc006a() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val t = readLine()!!

    for (i in 0 until n) {
        if (s.substring(i..s.lastIndex) == t.substring(0..s.lastIndex - i)) return println(n + i)
    }

    return println(n * 2)
}
