Problem:
 Score : 200 points    Problem Statement Snuke is interested in strings that satisfy the following conditions:   The length of the string is at least N .  The first N characters equal to the string s .  The last N characters equal to the string t .   Find the length of the shortest string that satisfies the conditions.      Constraints  1≤N≤100  The lengths of s and t are both N .  s and t consist of lowercase English letters.         Input The input is given from Standard Input in the following format:  N  s  t       Output Print the length of the shortest string that satisfies the conditions.        Sample Input 1 3
abc
cde      Sample Output 1 5  The shortest string is abcde .       Sample Input 2 1
a
z      Sample Output 2 2  The shortest string is az .       Sample Input 3 4
expr
expr      Sample Output 3 4  The shortest string is expr .

Solution (Python):
n = int(input())
s = input()
t = input()

for i in range(n, 2*n+1):
    if s[n - (2*n-i):] == t[:2*n-i]:
        print(i)
        exit()

Solution (Python):
n = int(input())
s = input()
t = input()

for i in range(n, 2*n+1):
    if s[n - (2*n-i):] == t[:2*n-i]:
        print(i)
        exit()

print(2*n)

Solution (Python):
N = int(input())
s = input()
t = input()

for i in range(N):
  if s[i:] == t[:N-i]:
    print(N+i)
    exit()
print(2*N)

Solution (Python):
N = int(input())
S = input()
T = input()
ans = S+T
for i in range(1,N+1):
    
    if S[-i:] == T[:i]:
        ans = S + T[i:]
print(len(ans))

Solution (Python):
n = int(input())
s = input()
t = input()
if s == t:
    print(n)
    exit()
t = t[::-1]
s = s[::-1]
res = n
j = 0
for i in range(n):
    if s[j]==t[i]:
        j += 1
    else:
        res += 1
print(res)

Solution (Python):
import sys
input=sys.stdin.readline

n=int(input())
s=input().rstrip()
t=input().rstrip()

for i in range(n+1):
    check=True
    for j in range(n-i):
        if s[i+j]!=t[j]:
            check=False

    if check:
        ans=i+n
        print(ans)
        sys.exit()

Solution (Python):
n = int(input())
s = input()
t = input()
p = n * 2

for i in range(n):
    if t[0:i+1] in s:
        p -= 1
    else:
        break

print(p)

Solution (Python):
n=int(input())
s=input()
t=input()
for i in range(n):
    i=n-i
    if s[n-i:]==t[:i]:
        print(n*2-i)
        exit()
print(2*n)

Solution (Python):
import sys
N = int(input())
s = input()
t = input()
for i in range(N):
    flg = True
    for j in range(N - i):
        if s[i + j] != t[j]:
            flg = False
            break
    if flg:
        print(N + i)
        sys.exit()
print(2 * N)

Solution (Python):
N=int(input())
S=input()
T=input()

k=0
for i in range(1,N+1):
    if S[-i:]==T[:i]:
        k=i
print(2*N-k)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    s = input()
    t = input()

    for i in range(n + 1):
        flag = True
        for j in range(n - i):
            if s[i + j] != t[j]:
                flag = False
                break
        if flag:
            return print(n + i)


if __name__ == '__main__':
    main()

Solution (Python):




n = int(input())
s = input()
t = input()
ans = n * 2

for i in range(n):
    j = 0
    while i + j < n :
        if s[i+j] != t[j]:
            break
        j = j + 1

    if i + j == n:
        ans = j + i * 2
        break

print(ans)

Solution (Python):
N = int(input())
s = str(input())
t = str(input())

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

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    n = int(input())
    s = input()
    t = input()
    for i in range(n, 0, -1):
        x = s[-i:]
        y = t[:i]
        if x == y:
            print(len(s[:n-i] + t))
            return
    print(n*2)


    

t = 1

for case in range(1,t+1):
    ans = solve()


"""



"""

Solution (Python):
n = int(input())
s = list(input())
t = list(input())
cnt = 0
for i in range(min(len(s), len(t))):
    c = 0
    for j in range(i + 1):
        if s[len(s) - 1 - i + j] == t[j]:
            c += 1
    cnt = max(cnt, c)
ans = len(s) + len(t) - cnt
if ans < n:
    ans = n
print(ans)

Solution (Python):
n=int(input())
s=input()
t=input()
for i in range(n+1):
    if s[i:]==t[:n-i]:
        print(n+i)
        break

Solution (Python):
n=int(input())
s=input()
t=input()
flg=True
tmp=0
if s==t:
    print(n)
    exit()
for i in range(1,n):
    ss=s[i:]
    tt=t[:-i]
    if ss==tt:
        print(2*n-len(ss))
        exit()
print(n*2)

Solution (Python):
N = int(input())
s = input()
t = input()

dupe = 0
for i in range(N):
    for j in range(N + 1):
        if s[i:] == t[:j]:
            dupe = max(dupe, len(s[i:]))
print(N * 2 - dupe)

Solution (Python):
N = int(input())
s = input()
t = input()

for i in range(N+1):
    if s[i:] == t[:N-i]:
        print(N+i)
        break

Solution (Python):
n = int(input())
s = input()
t = input()

for i in range(n, 2 * n):
    check = 2 * n - i
    ss = s[-1 * check:]
    tt = t[:check]
    if ss == tt:
        print(i)
        exit()

print(2 * n)

Solution (Python):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
s = input()
t = input()

if n>=len(s)+len(t):
  print(n)
  exit()

de = 0
for i in range(min(len(s),len(t))):
  if s[i*-1-1:]==t[:i+1]:
    de = i+1

print(len(s)+len(t)-de)

Solution (Python):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
s = input()
t = input()

if s==t and len(s)>=n:
  print(len(s))
  exit()
if n>=len(s)+len(t):
  print(n)
  exit()

de = 0
for i in range(min(len(s),len(t))):
  if s[i*-1-1:]==t[:i+1]:
    de = i+1

print(len(s)+len(t)-de)

Solution (Python):
n = int(input())
s = input()
t = input()

min_len = 2 * n
for i in range(n):
    if s[-1 - i:] == t[:i+1]:
        min_len = min(min_len, 2 * n - i - 1)
print(min_len)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Solution (Python):
n = int(input())
s = input()
t = input()
num = 0
for i in range(1, n+1):
    if s[-i:] == t[:i]:
        num = i

print(n*2 - num)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    s = input()
    t = input()
    count = 2 * n
    maxDiff = 0

    for i in range(0,n+1):
        diff = 0
        for j in range(i):
            if s[n - i :][j] == t[j]:
                diff+=1
            else:
                break
        if maxDiff < diff:
            maxDiff=diff
    print(count-maxDiff)

Solution (Python):
N = int(input())
s = input()
t = input()

if s == t:
  print(N)
else:
  for i in range(1, N):
    if s[i:] == t[:-i]:
      print(N + i)
      exit()
  print(N * 2)

Solution (Python):
N=int(input())
s=input()
t=input()
ans=10**9
for i in range(N+1):
    for j in range(N+1):
        u=s[:i]+t[j:]
        if len(u)<N:
            continue
        if u[:N]==s and u[-N:]==t:
            ans=min(ans,len(u))
print(ans)

Solution (Python):
n=int(input())
s=input()
t=input()
while True:
  if s==t:
    break
  s=s[1:]
  t=t[:-1]
  n+=1
print(n)

Solution (Python):

N=int(input())
S=input()
T=input()
L=min(len(S), len(T))

count=0
for i in range(N):
    if S[-(i+1):]==T[:(i+1)]:
        count=(i+1)

print(len(S)+len(T)-count)

Solution (Python):
N=int(input())
s=input()
t=input()
for x in range(N):
    for y in range(N-x):
        if s[x+y] != t[y]:
            break
    else:
        print(N+x)
        break
else:
    print(N*2)

Solution (Python):
n = int(input())
s = input()
t = input()
f = 0
m = 0
ind = 0
for i in range(1,n+1):
      if(s[n-i:]==t[:i]):
            f=1
            if (len(t[:i])>m):
                  m = len(t[:i])
                  ind = i

print(2*n-ind) if f==1 else print(2*n)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
 
n = inp()
s = input()
t = input()
for i in range(n):
    for j in range(n-i):
        if s[i+j] != t[j]:
            break
    else:
        print(n+i)
        break
else:
    print(n*2)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = input()
t = input()
for i in range(n):
    for j in range(n-i):
        if s[i+j] != t[j]:
            break
    else:
        print(n+i)
        break
else:
    print(n*2)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
s = str(input())
t = str(input())

for i in range(N):
    if s[i:]==t[:N-i]:
        break
else:
    i += 1
print(N+i)

Solution (Python):
n = int(input())
s = input()
t = input()

for i in range(n):
    if s[i:] == t[:n-i]:
        print(n + i)
        exit()
else:
    print(n*2)

Solution (Python):
N = int(input())
s = input()
t = input()

ti = 1
ma = 0
for i in range(N - 1, -1, -1):
    if s[i:] == t[:ti]:
        ma = ti    
    ti += 1
print(2 * N - ma)

Solution (Python):
N = int(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)

Solution (Python):

def main():
    n = int(input())
    s = input()
    t = input()

    if s == t:
        print(n)
        return

    for i in reversed(range(0, n)):
        target = s + t[i:]
        if target.startswith(s) and target.endswith(t):
            print(len(target))
            return

main()

Solution (Python):
n = int(input())
s = input()
t = input()

for i in range(len(s)):
    if s[i] != t[0]: continue
    if s[i:] == t[:len(s)-i]:
        print(i+len(t))
        exit()
print(len(s)+len(t))

Solution (Python):
n = int(input())
s = str(input())
t = str(input())
val = s+t
for i in range(min(len(s),len(t))):
  if s[-1-i:] == t[:i+1]:
    val = s+t[i+1:]
 
print(len(val))

Solution (Python):
n=int(input())
s=str(input())
t=str(input())
 
if s==t:
    print(n)
else:
    for i in range(1,n+1):
        x = s + t[-i:]
        if x[-n:] == t:
            break
    print(len(x))

Solution (Python):
N = int(input())
s = input()
t = input()

for i in range(N):
    tmp = 0
    while True:
        if s[i+tmp] == t[tmp]:
            pass
        else:
            break

        tmp += 1
        if not i + tmp < N:
            print(i + N)
            exit(0)
print(2*N)

Solution (Python):
N = int(input())
s = input()
t = input()
count = 0
num_s = len(s)
num_t = len(t)

for i in range(num_t):
    for j in range(i, num_s):
        if t[count] == s[j]:
            count += 1
        else:
            count = 0
            break

    if count == num_t - i:
        break
print(num_s+num_t-count)

Solution (Python):
n = int(input())
s = input()
t = input()

for i in range(0,n):
    if s[i:] == t[:n-i]:
        print(n+i)
        exit()
print(2*n)

Solution (Python):
N = int(input())
s = input()
t = input()

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

Solution (Python):
N = int(input())
s = input()
t = input()

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

Solution (Python):
N = int(input())
s = input()
t = input()

ans = len(s) + len(t)
for i in range(len(s)):
    if t[:i+1] in s:
        ans = min(ans, len(s) + len(t) - (i+1))
        
print(ans)

Solution (Python):
n = int(input())
s = input()
t = input()
for i in range(n+1):
    k = s[:i] + t
    if k[:n] == s:
        print(n+i)
        break

Solution (Python):
n = int(input())
s = input()
t = input()
for i in range(n):
    if s == t:
        print(len(s))
        exit()
    if s[i:] == t[:n-i]:
        print(len(s+t[-i:]))
        exit()
print(len(s+t))

Solution (Python):
import sys
n = int(input())
pre = input()
suf = input()
if pre==suf:
    print(n)
    sys.exit()
slicer, ans = n-1 , n*2
for xx in range(n+1):
    if suf[:slicer] in pre:
        ans = len(pre)+(len(suf)-len(suf[:slicer]))
        break
    slicer-=1
print(ans)

Solution (Python):
import sys
n = int(input())
pre = input()
suf = input()
if pre==suf:
    print(n)
    sys.exit()
slicer, ans = n-1 , n*2
for xx in range(n+1):
    if suf[:slicer] in pre:
        ans = len(pre)+(len(suf)-len(suf[:slicer]))
        break
    slicer-=1
print(ans)

Solution (Python):
n = int(input())
s = str(input())
t = str(input())
for i in range (n+1):
  b = s[0:i] + t[0:n]
  if b[0:n] == s:
    n += i
    break
print(n)

Solution (Python):
n = int(input())
s = input()
t = input()
answer = n
for i in range (n + 1) :
  newstring = s[0:i] + t[:n]
  if newstring[0:n] == s:
    answer += i
    break
print (answer)

Solution (Python):
N=int(input())
s=str(input())
t=str(input())

if s==t:
    print(len(s))
    exit()

for i in range(1,N+1):
    ans = s + t[-i:]
    if ans[-N:] == t:
        break
print(len(ans))

Solution (Python):
N = int(input())
s = input()
t = input()
for i in range (N+1):
  k = s[:i] + t
  if k[:N] == s:
    print(N+i)
    break

Solution (Python):
N = int(input())
s = str(input())
t = str(input())

if s==t:
    print(len(s))
    exit()

for i in range(1,N+1):
    ans = s + t[-i:]
    if ans[-N:] == t:
        break
print(len(ans))

Solution (Python):
N = int(input())
S = str(input())
T = str(input())
ans = S+T
for i in range(min(len(S),len(T))):
  if S[-1-i:] == T[:i+1]:
    ans = S+T[i+1:]

print(len(ans))

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, S, T = read().split()
N = int(N)

def test(n):
    overlap = N + N - n
    if overlap <= 0:
        return True
    return S[-overlap:] == T[:overlap]

for n in range(N, N + N + 10):
    if test(n):
        break
print(n)

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
s=list(input())
t=list(input())
for i in range(n):

    if s[i:]==t[:n-i]:
        print(n+i)
        exit()
print(2*n)

Solution (Python):
N = int(input())
s = input()
t = input()
ans = 2*N
for i in range(N):
  A = s[:i] + t
  if A[:N] == s:
    ans = N+i
    break
print(ans)

Solution (Python):
N=int(input())
s=input()
t=input()

for i in range(N):
    F=0
    for j in range(i,N):
        if s[j]==t[j-i]:
            continue
        else:
            F=1
            break
    if F==0:
        print(len(s[:i]+t))
        exit()
print(2*N)

Solution (Python):
n = int(input())
s = input()
t = input()
cou = 0
for i in range(n):
  s1 = s[i:]
  t1 = t[:n-i]

  if s1==t1:
    print(2*n-(n-i))
    exit()
else:
  print(2*n)

Solution (Python):
n = int(input())
s = input()
t = input() + 'x'

for i in range(n):
    if s[i:]==t[:~i]:
        print(n+i)
        exit()

print(2*n)

Solution (Python):
n=int(input())
s=input()
t=input()
cnt=0
for i in range(min(len(s),len(t))+1):
    
    if s[len(s)-i:]==t[:i]:
        cnt=i
    

print(len(s)+len(t)-cnt)

Solution (Python):
n=int(input())
s=input()
t=input()

for i in range(n,2*n+1):
  a=s[:n]+t[2*n-i:]
  if a[-n:]==t:
    print(i)
    exit(0)

Solution (Python):
import sys
readline = sys.stdin.readline

N = int(readline())
S = readline().rstrip()
T = readline().rstrip()

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


  if S[-i:] == T[:i]:
    print(N * 2 - i)
    break
else:
  print(N * 2)

Solution (Python):
n = int(input())
s = input()
t = input()

ans = ""
for i in range(n):
    if s[i] == t[0] and s[i:] == t[:n-i]:
        ans = s[:i]+t
        break
print(n*2 if ans=="" else len(ans))

Solution (Python):
n=int(input())
s=input()
t=input()
actualfail=0
for i in range(n):
  fail=0
  for j in range(n-i):
    if s[i+j]!=t[j]:
      fail=1
      break
  if fail==0:
    actualfail=1
    break
if actualfail==1:
  print(n+i)
else:
  print(2*n)

Solution (Python):
n = int(input())
s = input()
t = input()
x = 0
for i in range(n):
    if s[n-i-1:]==t[:i+1]:
        x = i+1
print((n*2)-x)

Solution (Python):
N = int(input())
s = input()
t = input()
sameLen = 0
for i in range(N):
    if s[i:] == t[: N - i]:
        sameLen = N - i
        break
print(2 * N - sameLen)

Solution (Python):
N = int(input())
s = input()
t = input()
sameLen = 0
for i in range(N):
    if s[i:] == t[: N - i]:
        sameLen = N - i
        break
    else:
        continue
if sameLen == 0:
    print(2 * N)
else:
    print(2 * N - sameLen)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
s = input()
t = input()

if s == t:
	print(N)
	exit()

for i in range(1, N):
	if s[i:] == t[:-i]:
		print(2*N - len(s[i:]))
		break
else:
	print(2*N)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
s = input()
t = input()

if s == t:
	print(N)
	exit()

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

Solution (Python):
n=int(input())
s=str(input())
t=str(input())
s=list(s)
t=list(t)
ans=2*n
for i in range(n):
  cnt=0
  for j in range(n-i):
    if s[i+j]!=t[j]:
      break
    else:
      cnt=cnt+1
  if cnt==n-i:
    ans=ans-n+i
    break
print(ans)

Solution (Python):
n = int(input())
s = input()
t = input()
cnt = 0
for i in range(n):
  if s[-1-i:] == t[:i+1]:
    cnt = i + 1
print(n*2-cnt)

Solution (Python):
n=int(input())
s=input()
t=input()
c=0
for i in range(n):
    
    
    if s[-i-1:]==t[:i+1]:
        c=i+1
print(n*2-c)

Solution (Python):

def resolve():
    n = int(input())
    s = input()
    t = input()
    ans = len(s) + len(t)
    for i in range(len(s)):
        pos = 0
        for ss,tt in zip(s[i:],t):
            if ss != tt:
                break
            pos += 1
        else:
            if len(s) - i > len(t) or i + len(t) < n:
                continue
            tmp = i + len(t)
            if tmp < ans:
                ans = tmp
    print(ans)
        

if __name__ == "__main__":
    resolve()

Solution (Python):

N = int(input())
S = list(input())
T = list(input())
ans = N*2
for i in range(N):
    
    if S[N-1-i:] == T[:i+1]:
        
        ans = N*2-(i+1)
print(ans)

Solution (Python):



def main():
    N = int(input())
    S = input()
    T = input()

    ret = 2*N
    for i in range(N):
        if S[i:]==T[:N-i]:
            ret = 2*N-(N-i)
            break
    print(ret)



if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = input()
b = input()
ans = ''
idx1 = 0
idx2 = n
while idx1 < n and a[idx1:] != b[:idx2]:
    idx1+=1
    idx2-=1
print(2*n - idx2)

Solution (Python):
n=int(input())
s=input()
t=input()
if s==t:
    print(n)
    exit()
for i in range(n):
    if s[i:]==t[:-i]:
        print(n+i)
        exit()
print(n*2)

Solution (Python):
N=int(input())
S=input()
T=input()

ans=2*N
i=N
while i:
    if S[-i:]==T[:i]:
        ans-=i
        break
    i-=1

print(ans)

Solution (Python):
N=int(input())
s=input()
t=input()
count=0
for i in range(N):
    if s[N-i-1:]==t[:i+1]:
        count=i+1
print(N*2-count)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N = I()
A = S()
B = S()

if A==B:
  print(len(A))
  exit()

for i in range(1,N):
  if A[i:] == B[:-i]:
    print(len(A[:i]+B))
    exit()
    
print(len(A+B))

Solution (Python):
n=int(input())
s=input()
t=input()
c=0
for i in range(n):
 if s[-i-1:]==t[:i+1]:
  c=i+1
print(n*2-c)

Solution (Python):
N=int(input())
s=input()
t=input()
chohuku=0
for i in range(N):
  if s[i:]==t[:N-i]:
    chohuku=len(s[i:])
    break
print(N+N-chohuku)

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  


N = read_a_int()
s = input()
t = input()


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

Solution (Python):
n = int(input())
s = input()
t = input()
if s==t:
    print(len(s));exit()

ans = n*2
for i in range(n):
    if s[i:]==t[:n-i]:
        ans = n+i

print(ans)

Solution (Python):
N = int(input())
S = input()
T = input()
ren = 0
for i in range(N):
    A = S[-(i+1):]
    B = T[:(i+1)]
    if A == B:
        ren = i+1
print(2*N-ren)

Solution (Python):
n = int(input())
s, t = input(), input()

ans = 1<<30
for i in range(len(s)+1) :
  st = s[0 : i] + t
  if len(st) >= n and st[ : n] == s and st[-n : ] == t :
    ans = min(ans, len(st))
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    s = input().strip()
    t = input().strip()
    return N, s, t


def solve(N, s, t):
    for i in range(N, 0, -1):
        sl = N - i
        tr = i
        if s[sl:] == t[:tr]:
            return 2 * N - i
    return 2 * N


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))

Solution (Python):
n=int(input())
s=input()
t=input()
c=0
for i in range(n):
    if s[-i-1:]==t[:i+1]:
        c=i+1

ans=2*n-c
print(ans)

Solution (Python):
n = int(input())
s = input()
t = input()

for i in range(len(s)):
    if s[i:] == t[:n-i]:
        print(n+i)
        exit()

print(n*2)

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)

mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = int(input())
s = input()
t = input()
cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == t[cnt]:
        cnt += 1
    elif s[i] != t[cnt] and s[i] == t[0]:
        ans = max(ans,cnt)
        cnt = 1
    else:
        ans = max(ans,cnt)
        cnt = 0
print(n + n - cnt)

Solution (Python):
N = int(input())
s = list(input())
t = list(input())
ans = 2*N
for i in range(N):
  if s[i:] == t[:(N-i)]:
    ans = N+i
    break
print(ans)

Solution (Python):
N = int(input())
s = input()
t = input()
ans=maxlen=len(s)+len(t)

for i in range(len(s)):
  if len(s[i:]) <= len(t):
    complen = len(s[i:])
    if maxlen-complen>=N and s[i:] == t[0:complen]:
      ans=maxlen-complen
      break
      
      
print(ans)

Solution (Python):
N = int(input())
S = input()
T = input()
for i in range(N + 1):
    if S[i:] == T[: N - i]:
        print(N + i)
        break

Solution (Python):
n = int(input())
s = str(input())
t = str(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)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
s = input()
t = input()

ans = 10**10

for i in range(n - 1, -1, -1):
    if s[i:] == t[:n-i]:
        if len(s) + len(t[n-i:]) >= n:
            ans = min(ans, len(s) + len(t[n-i:]))
if len(s) + len(t) >= n:
    ans = min(ans, len(s) + len(t))

if ans == 10**10:
    print(n)
else:
    print(ans)

Solution (Python):
n = int(input())
s = input()
t = input()

ok = False
for i in range(n):
  if s[i:n] == t[:n-i]:
    ok = True
    break
print(n+i if ok else n*2)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
s = input()
t = input()
if s == t:
	print(N)
	exit()

for i in range(1, N):
	s1 = s[i:]
	t1 = t[:-i]
	if s1 == t1:
		print(2*N-len(s1))
		break
else:
	print(2*N)

Solution (Python):
N = int(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)

Solution (Python):
N = int(input())
s = input()
t = input()

max_i = 0
for i in range(N+1):
    if s[N-i:] == t[:i]:
        max_i = i

ans = s[:N-max_i] + t
print(len(ans))

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
s = input()[:-1]
t = input()[:-1]

for match in range(N, 0, -1):
    if s[N-match:]==t[:match]:
        print(2*N-match)
        exit()

print(2*N)

Solution (Python):
n=int(input())
s=input()
t=input()
for i in range(n,2*n+1):
  a=s[:n]+t[2*n-i:]
  if a[-n:]==t:exit(print(i))

Solution (Python):
n = int(input())
s = input()
t = input()
if s == t:
    print(len(s))
    exit()
for i in range(1, n):
    if s[i:] == t[:-i]:
        print(len(s) + i)
        break
else:
    print(len(s) * 2)