n = int(eval(input()))

s = str(eval(input()))

t = str(eval(input()))



temp = 0

for i in range(n+1):

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

        temp = i



ans = 2*n-temp

print(ans)

n = int(eval(input()))

s = str(eval(input()))

t = str(eval(input()))



if s == t:

    print(n)

    exit()



for i in range(n):

    #print(s[i:], t[:n-1-i+1])

    if s[i:] == t[:n-1-i+1]:

        break

else:

    i = n

    #pass

ans = i*2+(n-i)

print(ans)

n = int(eval(input()))
s = str(eval(input()))
t = str(eval(input()))
temp = 0
for i in range(n + 1):
    if t[0:i] == s[n - i : n]:
        temp = i
ans = 2 * n - temp
print(ans)

n = int(eval(input()))
s = str(eval(input()))
t = str(eval(input()))
if s == t:
    print(n)
    exit()
for i in range(n):
    # print(s[i:], t[:n-1-i+1])
    if s[i:] == t[: n - 1 - i + 1]:
        break
else:
    i = n
    # pass
ans = i * 2 + (n - i)
print(ans)

-temp = 0 -for i in range(n + 1): -    if t[0:i] == s[n - i : n]: -        temp = i -ans = 2 * n - temp +if s == t: +    print(n) +    exit() +for i in range(n): +    # print(s[i:], t[:n-1-i+1]) +    if s[i:] == t[: n - 1 - i + 1]: +        break +else: +    i = n +    # pass +ans = i * 2 + (n - i)