N = int(eval(input()))

s = eval(input())

t = eval(input())

idx = 0

for i in range(N):

    tmp_s = s[N - i - 1:]

    tmp_t = t[:i + 1]

    if tmp_s == tmp_t:

        idx = i + 1



print((len(s + t[idx:])))

N = int(eval(input()))

s = eval(input())

t = eval(input())

ans = s

for i in range(N + 1):

    tmp_ans = s + t[i:]

    # print(tmp_ans)

    if tmp_ans[:N] == s and tmp_ans[-N:] == t:

        ans = tmp_ans

print((len(ans)))

N = int(eval(input()))
s = eval(input())
t = eval(input())
idx = 0
for i in range(N):
    tmp_s = s[N - i - 1 :]
    tmp_t = t[: i + 1]
    if tmp_s == tmp_t:
        idx = i + 1
print((len(s + t[idx:])))

N = int(eval(input()))
s = eval(input())
t = eval(input())
ans = s
for i in range(N + 1):
    tmp_ans = s + t[i:]
    # print(tmp_ans)
    if tmp_ans[:N] == s and tmp_ans[-N:] == t:
        ans = tmp_ans
print((len(ans)))

-idx = 0 -for i in range(N): -    tmp_s = s[N - i - 1 :] -    tmp_t = t[: i + 1] -    if tmp_s == tmp_t: -        idx = i + 1 -print((len(s + t[idx:]))) +ans = s +for i in range(N + 1): +    tmp_ans = s + t[i:] +    # print(tmp_ans) +    if tmp_ans[:N] == s and tmp_ans[-N:] == t: +        ans = tmp_ans +print((len(ans)))