N = int(eval(input()))

s = input().strip()

t = input().strip()

ans = 2*N

for i in range(N):

    if s[i:]==t[:N-i]:

        ans = N+i

        break

print(ans)
N = int(eval(input()))

s = input().strip()

t = input().strip()

k = 0

for i in range(1,N+1):

    if s[-i:]==t[:i]:

        k = i

        continue

print((2*N-k))
N = int(eval(input()))
s = input().strip()
t = input().strip()
ans = 2 * N
for i in range(N):
    if s[i:] == t[: N - i]:
        ans = N + i
        break
print(ans)

N = int(eval(input()))
s = input().strip()
t = input().strip()
k = 0
for i in range(1, N + 1):
    if s[-i:] == t[:i]:
        k = i
        continue
print((2 * N - k))

-ans = 2 * N -for i in range(N): -    if s[i:] == t[: N - i]: -        ans = N + i -        break -print(ans) +k = 0 +for i in range(1, N + 1): +    if s[-i:] == t[:i]: +        k = i +        continue +print((2 * N - k))