fun main(args: Array<String>) {
    val N = nextInt()
    val S = next()
    val T = next()
    var n = 0
    while (n < N) {
        var m = N - n
        while (m > 0) {
            if (S.substring(n) == T.substring(0, m)) {
                println(N + N - m)
                return
            }
            m--
        }
        n++
    }
    println(N+n)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
