fun main(args: Array<String>) {
    val n = readInt()
    val s = readString()
    val t = readString()
    
    for (i in n - 1 downTo 0) {
        if (s.substring(n - 1 - i until n) == t.substring(0..i)) {
            println(2 * n - (i + 1))
            return
        }
    }
    println(2 * n)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()