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()
ans = len(s) + len(t)
c= 0
for i in range(n):
    j = n-i
    if s[i:] == t[:j]:
        ans = len(s[i:]) + len(t[:i]) + c
        break
    else:
        c+=1
print(ans)

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



print(ret)

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

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

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

print(n * 2)

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

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

print(n * 2)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

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

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

lt = min(len(s), len(t))
i = -1
overlap = 0
for i in range(lt):
    if s[-(i + 1):] == t[:i + 1]:
        overlap = i + 1
        if lt >= 2 and s[-(i + 2):] != t[:i + 2]:
            break
    
ans = max(n, len(s) + len(t) - overlap)
print(ans)

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

Solution (Python):
import sys
def input():
  return sys.stdin.readline().rstrip()

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

def func():
  for i in range(N):
    if s[i:]==t[0:N-i]:
      return i+N
  return N*2

print(func())

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

Solution (Python):
N = int(input())
s = input()
t = 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()
duplicates = 0
for i in range(n):
    if s[-(i + 1):] == t[:i + 1]:
        duplicates = i + 1
temp = s + t[duplicates:]
print(len(temp))

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

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

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

i = 0
while i < N:
    if s[i:] == t[:N - i]:
        break
    i += 1
print(i + N)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq














import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
s = input()
t = input()
if s == t:
    print(n)
    exit()
cnt = 0
for i in range(n):
    suf = s[-i-1:]
    pre = t[:i+1]
    
    if s[-i-1:] == t[:i+1]:
        cnt = len(pre)
print(n + n - cnt)

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

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

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

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

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

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

Solution (Python):
N = int(input())
s = input()
t = input()
c = 0
for o in range(len(s) + 1):
    d = 0
    for i in range(len(t)):
        if o + i >= len(s): break
        if s[o + i] == t[i]: d += 1
        else: break
    c = max(c, d)
print(len(s) + len(t) - c)

Solution (Python):
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







n = I()
s = S()
t = S()

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

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

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

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

Solution (Python):
n = int(input())
s = input()
t = input()
flag = False
for i in range(n):
    if s[i:] == t[:n-i]: 
        flag = True
        break
print(i+n if flag else n*2)

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

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

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

Solution (Python):
N = int(input())
A = input()
B = input()

for i in range(N):
  if A[i:] == B[0:N-i]:
    print(N+i)
    exit(0)
    
print(N*2)

Solution (Python):
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    s, t = input(), input()

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

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a, b = [input() for i in range(2)]
for i in range(n+1):
  if a[i:] == b[:n-i]:
    print(i + n)
    break

Solution (Python):
n=int(input())
s=str(input())
t=str(input())
    
cnt=0

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

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(n*2)

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

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

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


if __name__ == "__main__":
    main()

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

ans = N*2
for n in range(N):
    if s[n:] == t[:N-n]:
        ans -= len(s[n:])
        break
        
print(ans)

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

ans = N*2
for n in range(N):
    if s[n:] == t[:N-n]:
        ans -= len(s[n:])
        break
        
print(ans)

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N = int(input())
s,t = input(),input()
i = N
while i>0 and s[N-i:]!=t[:i]:
    i -= 1
print(2*N-i)

Solution (Python):
n = int(input())
s = list(str(input()))
t = list(str(input()))
ans = 0

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


print(n*2 - ans)

Solution (Python):
n=int(input())
s=input()
t=input()
if n==1 and s!=t:
  print(2)
  exit()
if n==1 and s==t:
  print(1)
  exit()
ans=2*n
for i in range(n):
  if s[i:n]==t[0:n-i]:
    ans-=n-i
    break
print(ans)

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

find = False
for i in range(N):
    mae = s[i:]
    ushiro = t[0:N-i]
    if mae == ushiro:
        find = True
        break
if find:
    print(N+i)
else:
    print(N*2)

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

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

print(N * 2)

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

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

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

Solution (Python):

N = int(input())
s = list(input())
t = list(input())
s_rev = list(reversed(s))

cnt = 0
for i in range(1,N+1):
    
    tgt = list(reversed(s_rev[:i]))
    if tgt == t[:i]:
        cnt = len(tgt)
    
ans = s + t[cnt:]
print(len(ans))

Solution (Python):
import sys
n = int(input())
s = list(input())
t = list(input())

if s == t:
    print(n)
    sys.exit()
can = False
for i in range(n):
    if s[i:n] == t[0:(n-i)]:
        can = True
        break
if can:
    print(n + i )
else:
    print(2*n)

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

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

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

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	n = int(input())
	
	s = input()
	t = input()
	if s == t:
		return n
	for i in range(1, n+1):
		r = s + t[-i:]
		if r[-n:] == t:
			return i+n
	
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

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

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    s = S()
    t = S()

    lenth = 0

    for i in range(1,n+1):
        s_end = s[-i:]
        t_start = t[:i]

        if s_end == t_start:
            lenth = i
    
    ans = 2*n - lenth
    print(ans)
        
main()

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

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

ans = s + t
for i in range(n):
    is_same = True
    for j in range(i, n):
        if s[j] != t[j - i]:
            is_same = False
            break
    if is_same:
        ans = s[:i] + t
        break

print(len(ans))

Solution (Python):

N = int(input())
S = input()
T = input()

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

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

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

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

Solution (Python):
N = int(input())
S = input()
T = input()
kouho = []
for i in range(len(S)):
    ok = 1
    for j in range(0, len(S)-i):
        if S[i+j] == T[j]:
            continue
        ok = 0
        break
    if ok == 0:
        continue
    break
if ok == 1:
    ans = i+len(T)
else:
    ans = len(S)+len(T)
print(ans)

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

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

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

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

for i in range(1, n):
    s_ = s[i:n]
    t_ = t[0:n-i]
    if s_ == t_:
        ans = s[:i]+t
        print(len(ans))
        exit()
else:
    print(2*n)

Solution (Python):
N = int(input())
s = input().strip()
t = input().strip()
flag = 0
for k in range(N,0,-1):
    if s[N-k:]==t[:k]:
        flag = k
        break
print(2*N-flag)

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    s = ins()
    t = ins()
    for i in range(n + 1):
        if t.startswith(s[i:]):
            return len(s[:i] + t)

    return len(s + t)


print(solve())

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

Solution (Python):
N = int(input())
s = input()
t = input()
ans = N
i = 0
if s == t:
    print(ans)
    exit()
while ans < 2 * N:
    if s[i:] == t[:-i]:
        break
    i += 1
    ans += 1
print(ans)

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

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

for i in range(1,n):
    sub_s=s[i:]
    sub_t=t[:-i]

    if sub_s==sub_t:
        print(n+i)
        exit()

print(n*2)

Solution (Python):

def check(moji):
    x1=""
    x2=""
    for i in range(n):
        x1+=moji[i]
        x2+=moji[len(moji)-n+i]
    if s==x1 and t==x2:
        return True
    else:
        return False
n=int(input())
s=input()
t=input()
ans=[]
ans.append(s)
for i in range(len(t)-1,-1,-1):
    ans.append(s+t[i:])
for i in ans:
    if check(i):
        print(len(i))
        break

Solution (Python):
N = int(input())
s = input()
t = input()
for i in range(N, -1, -1):
    if s.endswith(t[:i]):
        print(N+len(t)-i)
        exit()

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

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

Solution (Python):
n=int(input())
f=input()
b=input()
for x in range(n):
    if f[x:]==b[:n-x]:print(n+x);break
else:print(n*2)

Solution (Python):
N = int(input())
s = input()
t = input()
l1 = len(s)
l2 = len(t)
ans = l1+l2
for i in range(1,min(l1,l2)+1):
    if s[l1-i:] == t[:i]:
        ans = l1+l2-i
print(ans)

Solution (Python):
n = int(input())
s = input()
t = input()
ans = n
for i in range(n):
    f = True
    for j in range(n - i):
        f &= s[j + i] == t[j]
    if f:
        ans = i
        break
print(n+ans)

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

n = 0

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

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

Solution (Python):



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

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

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

Solution (Python):
N = int(input())
S = input()
T = input()
for i in range(N, 0, -1):
    if S[-i:] == T[:i]:
        print(2 * N - i)
        break
else:
    print(2 * N)

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

Solution (Python):
N = int(input())
s = input()
t = input()
if s == t:
    print(N)
    exit(0)
ans = 2*N
for k in range(1,N+1):
    if s[k:] == t[:-k]:
        ans = min(ans,2*N-len(s[k:]))
print(ans)

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

tmp = -1
for i in range(n):
    if s[-i - 1:] == t[:i + 1]:
        tmp = i


print(n + n - (tmp + 1))

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
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+n)

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

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

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

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

Solution (Python):
def solve():
  N = int(input())
  S = input()
  T = input()
  for i in range(N):
    if S[i:]==T[:N-i]:
      return N+i
  return N*2
print(solve())

Solution (Python):
N = int(input())
s = input().strip()
t = input().strip()
lmin = 2*N
for i in range(1,N+1):
    if s[-i:]==t[:i]:
        lmin = min(lmin,2*N-i)
print(lmin)

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

ans = 0
for i in range(n):
    curr_s = s[i:]
    cnt = 0
    for j in range(n-i):
        if t[j] == curr_s[j]: cnt += 1
        else: break
    ans = max(ans,cnt)

ans = n*2 - ans
print(ans)

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

for i in range(n):
    if s[i] == t[0]:
        if s[i:] == t[:n-i]: break
if s[i] != t[0]: i += 1
print(len(s[:i]+t))

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+N)

Solution (Python):
n = int(input())
s = input()
t = input()
ans = 2*n
for i in range(n):
    check = True
    for j in range(n-i):
        if s[i+j] != t[j]:
            check = False
            break
    if check:
        ans = min(ans,i+n)
print(ans)

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

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

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

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

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

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

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    S = input()
    T = input()

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


main()

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

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

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

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

cnt = 0
for i in range(N):
  tmp_s = s[i:]
  tmp_t = t if i == 0 else t[:-i]

  tmp_cnt = 0
  for j in range(len(tmp_s)):
    if tmp_s[j] == tmp_t[j]:
      tmp_cnt += 1

  cnt = max(cnt, tmp_cnt)

print(2 * N - cnt)

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

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

for i in reversed(range(n)):
    tmp = s + t[i:]
    if tmp.startswith(s) and tmp.endswith(t):
        print(len(tmp))
        exit()

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()

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

print(len(ans))

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

if (n == len(s) and (s == t)):
    print(n)
else:
    ind = [0]
    for i in range(1, len(s)):
        if s[-i:] == t[:i]:
            ind.append(i)

    ind.reverse()
    for i in ind:
        if i == 0:
            print(2*n)
        else:
            res = s[0:-i] + t
            if len(res) >= n:
                print(len(res))
                break

Solution (Python):
N=int(input())
a=input()
b=input()
ans=2*N

for i in range(1,N+1):
    if a[N-i:]==b[:i]:
        ans=2*N-i

print(ans)

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

    ans = 2 * N
    for i in range(N):
        s_ = s[i:]
        t_ = t[:len(t) - i]

        if s_ == t_:
            tmp = s + t[len(t) - i:]
            ans = min(ans, len(tmp))

    print(ans)

if __name__ == "__main__":
    main()

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

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

Solution (Python):
n=input()
s=raw_input()
t=raw_input()
for i in xrange(0,n+1):
	if s[i:n]==t[0:n-i]:
		print n+i
		break

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

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

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

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
s = input()
t = input()
same = 0
for i in range(n):
    
    if s[n-i-1:] == t[:i+1]:
        same = i+1
print(len(s) + len(t) - same)

Solution (Python):
N = int(input())
s = input().strip()
t = input().strip()
ind = -1
for i in range(N):
    x = s[i:]
    y = t[:N-i]
    if x==y:
        ind = i
        break
if ind>=0:
    print(N+i)
else:
    print(2*N)

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

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

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

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

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

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

  else:
    cnt+=1
print(n*2)

Solution (Python):



def f(word,N,S,T):
    if word[:N]==S and word[-N:]==T:
        return True
    else :
        return False


N=int(input())
S=input()
T=input()

ans = N*2

for i in range (N):
    t=T[N-i:]
    word=S+t

    if f(word,N,S,T):
        if ans>len(word):
            ans=len(word)
    else:
        pass

print(ans)

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

Solution (Python):


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


def main():
  N = int(input())
  s = input()
  t = input()
  print(solve(N,s,t))
  return

if __name__ == '__main__':
  main()

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    s = S()
    t = S()
    cnt = 0
    for i in range(n):
        
        now = 0
        for j in range(n-i):
            if s[i:n][j] == t[:n-i][j]:now += 1
        cnt = max(cnt,now)
    print(2 * n - cnt)

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()

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

if lst:
    print(min(lst))
else:
    print(n*2)

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

ans = n

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

print(ans)

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

for i in range(n):
    if s[i:] == t[:n-i]:
        match = n-i
        break

print(2*n-match)

Solution (Python):

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

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

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

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

import re 


ans=s

k=-1
for i in range(n):
    tmp=''.join(t[:i+1])

    if tmp in ans:
        k=i

if k<n-1:
    ans+=''.join(t[k+1:])

print(len(ans))