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, t = input(), input()

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

ans = N * 2 - v
print(ans)

Solution (Python):

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

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

Solution (Python):

N = int(input())
s, t = [input() for _ in range(2)]

common = 0

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

print(N * 2 - common)

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

Solution (Python):


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

string = s + t
ans = len(string)

for i in range(len(string)):
    for j in range(i, len(string)):
        sub = string[:i] + string[j:]
        if len(sub) >= n:
            if sub[:n] == s and sub[-n:] == t:
                ans = min(ans, len(sub))
print(ans)

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

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

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

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

Solution (Python):
N = int(input())
s = input()
t = input()
ans = 2*N
for i in range(N):
  if s[-(i+1):] == t[:i+1]:
    ans = 2*N-(i+1)
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()
for i in range(n):
    if s[i:] == t[:n-i]:
        print(n-i+i*2)
        break
else:
    print(2*n)

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
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()

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

print(n*2)

Solution (Python):
n=int(input())
a=input()
b=input()
p=True
for i in range(n):
    if a[:i]+b[:n-i]==a:
        print(i+n)
        p=False
        break
if p:print(2*n)

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

ans=""
for i in range(N):
    ans=ans+s[i]

count=0

for i in range(N):
    flag=True
    for j in range(i+1):
        
        if s[N-1-i+j]==t[j]:
            pass
        else:
            flag=False
    if flag:
        count=i+1

for i in range(count,N):
    ans=ans+t[i]

print(len(ans))

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

for start in range(N):
    point=0
    check=False
    for i in range(start,N):
        if s[i] != t[point]:
            check=True
            break
        point+=1
    if not check:
        common=N-start
        break

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

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

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

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

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

Solution (Python):
def solve(n, s, t):
    if s == t:
        return n
    for common in range(n - 1, 0, -1):
        if s[-common:] == t[:common]:
            return 2 * n - common
    return 2 * n


n = int(input())
s = input()
t = input()
print(solve(n, s, t))

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()
ans=0
for i in range(n+1):
  if s[-i:]==t[:i]:
    ans=i
print(2*n-ans)

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

for i in range(N):
    for j, t in enumerate(T[:N-i]):
        if S[j+i] == t:
            continue
        else:
            break
    else:
        print(N+i)
        break
else:
    print(2*N)

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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



resolve()

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

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

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

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 = list(input())
t = list(input())
cnt = 0
if s==t:
    ans = N
    cnt = 1
elif N==1:
    ans = N*2
    cnt = 1
else:
    for i in range(N):
        if s[i:]==t[:-i]:
            cnt = 1
            ans = N*2 - (N-i)
print(ans) if cnt==1 else print(N*2)

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

for i in range(0, 101):
    temp = s[:i] + t
    if temp[:N] == s:
        print(N + i)
        break

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

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

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

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

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

for i in range(N, -1, -1):
    if s[-i:] == t[:i]:
        print(N + (N - i))
        break
else:
    print(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
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()

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

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

ans = len(s + t)
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()

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()
for i in range(n):
    if s[i:]==t[:n-i]:
        print(n+i)
        break
else:print(2*n)

Solution (Python):

n=int(input())
s=input()
t=input()
ans=2*n
for i in range(0,len(s)):
    if(s[i:]==t[:n-i]): ans=min(ans,i+n-i+i)
    
    
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)
        exit()

Solution (Python):

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

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

print(2*n -cnt)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
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 = list(input())
t = list(input())
ans = n
for i in range(2 * n, n - 1, -1):
    c = 1
    x = ["?"] * i
    y = ["?"] * i
    for j in range(n):
        x[j] = s[j]
        y[i - j - 1] = t[n - j - 1]
    
    for j in range(i):
        if x[j] != "?" and y[j] != "?":
            if not x[j] == y[j]:
                c = 0
    if c == 1:
        ans = i
print(ans)

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()
kaburi = 0
if s == t:
  print(N)
else:
  for i in range(N):
    if s[-(i+1):] == t[0:i+1]:
      kaburi = len(s[-(i+1):])
  print(2*N-kaburi)

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

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

Solution (Python):
n = int(input())
sl = list(input())
tl = list(input())

ans = 0
for i in range(n+1):
    if sl[-i:] == tl[:i]:
        ans = i

print(2 * n - ans)

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

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

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

print((N-cnt)+N)

Solution (Python):
N=int(input())
S=input()
T=input()
s=[str(c) for c in (S)]
t=[str(c) for c in (T)]
flag=0
score=N
for i in range (N,2*N):
  flag=0
  for j in range(N+N-i):
    if s[i-N+j]!=t[j]:
      flag=1
  if flag==0:
    score=i
    flag=2
  if flag==2:
    break
if flag==1:
  score=2*N
print(score)

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

best = float('inf')
for i in range(len(T)+1):
    s = S + T[i:]
    if s[::-1][:N][::-1] == T:
        best = min(best, len(s))

print(best)

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

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


if __name__ == '__main__':
    main()

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

if ans != -1:
    print(len(s[:ans]+t))
else:
    print(len(s+t))

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

Solution (Python):


N = int(input())
s = list(input())
t = list(input())
Flg = True
for i in range(N,-1,-1):
    if s[N-i:N] == t[:i]:
        ans = 2 * N - i
        Flg = False
        break

if Flg:
    ans = 2 * N
    if s[-1] == t[0]:
        ans = 2 * N - 1
print(ans)

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

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

print 2*N

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') 
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(sys.stdin.readline()) 
def ifn(): return float(sys.stdin.readline()) 
def isn(): return sys.stdin.readline().split() 
def imn(): return map(int, sys.stdin.readline().split()) 
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) 
def fmn(): return map(float, sys.stdin.readline().split()) 
def iln(): return list(map(int, sys.stdin.readline().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, sys.stdin.readline().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
s = input()
t = input()

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

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 = len(t[:i+1])
print(2*n-cnt)

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

idx = 0
ct = 0

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

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 = len(t[:i+1])
print(2*n-cnt)

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

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

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

ans = len(s) + len(t)
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()

ans = 2*N
for i in range(N) :
    flg = True
    for j in range(N-i) :
        if s[i+j] != t[j] :
            flg = False
    if flg == True :
        ans = N+i
        break

print(ans)

Solution (Python):
def main():
    length = int(input())
    s = input()
    t = input()
    overlap = 0
    for i in range(1, length + 1):
        if t[:i] == s[-i:]:
            overlap = i
    print(2 * length - overlap)


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
S=input()
T=input()
dup=0
for d in range(N+1):
  
  flag=True
  for i in range(N-d):
    
    if T[i]!=S[d+i]:
      
      flag=False
      break
  if flag:
    dup=N-d
    break
print(2*N-dup)

Solution (Python):
def main():
    N = int(input())
    S = input()
    T = input()
    if S == T:
        return print(len(S))
    ans = len(S) + len(T)
    if len(S) > len(T):
        for i in range(len(S) - len(T), len(S)):
            if S[i:] == T[:len(S[i:])]:
                ans -= len(S[i:])
                break
    else:
        for i in range(len(S), 0, -1):
            if T[:i] == S[len(S) - i:]:
                ans -= i
                break
    print(ans)


if __name__ == '__main__':
    main()

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

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

ans = s + t[idx:]

print(len(ans))

Solution (Python):

import sys

def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

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

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

    return

if __name__ == '__main__':
    main()

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

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

print(2 * n - i)

Solution (Python):

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

same = 0
for i in range(n):
    
    judge = 1
    for j in range(i+1):
        if not t[j]==s[n-1-i+j]:
            judge = 0
            break
    
    if judge==1:
        same = i+1

print(2*n - same)

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

Solution (Python):
import sys
f=1;k=0
N=int(input())
s=list(input())
t=list(input())
for i in range(N):
  for j in range(i,N):
    
    if s[j]==t[k]:
      f=f*1
    else:
      f=f*0
    k=k+1
  if f!=0:
    print(N+i)
    sys.exit()
  f=1
  k=0
print(N*2)

Solution (Python):
N = int(input())
s = input()
t = input()
ans = len(s) + len(t)
for i in range(N) :
    if s[N - 1 - i :] == t[:i + 1] :
        ans = len(s) + len(t) - (i + 1)
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 main():
    n = int(input())
    s = input().rstrip()
    t = input().rstrip()
    ans = 2*n
    for i in range(n):
        f = True
        for j in range(n-i):
            if s[i+j] != t[j]:
                f = False
                break
        if f:
            ans = i + n
            break
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):

def check(a, b):
    a = list(a)
    b = list(b)
    while b and a[-len(b):] != b:
        b.pop(-1)
    return len(b)
N = int(input())
A = input()
B = input()
print(N*2-check(A, B))

Solution (Python):

def check(a, b):
    a = list(a)
    b = list(b)
    while b and a[-len(b):] != b:
        b.pop(-1)
    return len(b)
N = int(input())
A = input()
B = input()
print(N*2-check(A, B))

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

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

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

res = 0
s_ = s[::-1]
for i in range(n+1):
    tmp = s_[:i]
    tmp = tmp[::-1]
    
    cnt = 0
    for j in range(len(tmp)):
        if tmp[j] == t[j]:
            cnt += 1
    res = max(res, cnt)
print(2*n - res)

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


ans = []

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

    
    ans.append(s[i])

else:
    ans+=t
    

print(len(ans))

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

c = None

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

match = N - c
ans = 2 * N - match

print(ans)

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

c = -1

for i in range(N):
    sp = s[i:]
    tp = t[:N-i]
    
    if sp == tp:
        c = i
        break

if c == -1:
    print(2*N)
else:
    match = N - c
    ans = 2 * N - match
    
    print(ans)

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

pos = 0

for i in range(N):
    c = 0
    for j in range(N-i):
        
        
        if s[i+j] == t[j]:
            c += 1
        else:
            break
    else:
        pos = max(pos, c)


ans = 2 * N - pos
print(ans)

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

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

ans = ''
for i in range(n):
  ss = s[n-i-1:]
  tt = t[:i+1]
  if ss == tt:
    ans = s[:n-i-1]+ss+t[i+1:]
if len(ans) == 0:
  print(len(s+t))
else:
  print(len(ans))

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 = n * 2
for i in range(n):
    if s[i:] == t[:n-i]:
        ans -= n - i
        break
print(ans)

Solution (Python):
n = int(input())
w1 = input()
w2 = input()

def joint(x,y):
    tmp = n
    tmp_x = x
    tmp_y = y
    while tmp_x != tmp_y:
        tmp_x = tmp_x[1:]
        tmp_y =  tmp_y[0:-1]
        tmp -= 1
    joi_x = x[0:n-tmp]
    return(joi_x+y)

print(len(joint(w1,w2)))

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

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

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

if w is not None:
    print(len(w))
else:
    print(2 * N)

Solution (Python):
n = int(input())
s = input()
t = input()
res = s+t
kekka = n*2
import copy
for i in range(n):
    tmp = list(res)
    del tmp[n]
    target = "".join(tmp)
    if target[:n] == s and target[-n:] == t:
        kekka = len(target)
        
    res = copy.deepcopy(tmp)

print(kekka)

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):
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())
a = input()
b = input()
if len(a) + len(b) < n:
  print(n)
else:
  result = len(a) + len(b)
  for i in range(1, min(len(a), len(b)) + 1):
    if len(a) + len(b) - i >= n and a[-i:] == b[:i]:
      result = min(result, len(a) + len(b) - i)
  print(result)

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

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

print(ans)

Solution (Python):
def main():
    N = int(input())
    s = input()
    t = input()
    if s == t:
        print(N)
    else:
        count = 1
        for i in range(1,N):
            tmp = s+t[-i:]
            if s == tmp[:N] and t == tmp[-N:]:
                break
            count += 1
        print(N+count)
if __name__ == '__main__':
    main()

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

flag = 0

for i in reversed(range(n)):
	j = (-1) * i - 1
	if t[:(i+1)] == s[j:]:
		flag = 1
		break
	else:
		continue

if i == 0 and flag == 0:
	print(len(s + t))
else:
	print(len(s[:j] + t))

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

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

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

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):
import re

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

c = 0
for i in range(len(s)):
    if re.match(s[i:], t):
        c = len(s)-i
        break

print(N*2 - c)

Solution (Python):
N = int(input())
s = input()
t = input()
lcm = 0
for i in range(N):
    f = False
    c = 0
    idx = 0
    for j in range(i, N):
        if s[j] == t[idx]:
            c += 1
        else:
            break
        idx += 1
    lcm = max(lcm, c)
print(N*2-lcm)

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

Solution (Python):
def pin(type=int):
    return map(type,input().split())

"""
バケットで管理したかったけど数字が多いのでソートして同じ数を固めることに
"""


N=int(input())
S=input()
T=input()
ans=""
for i in range(N):
    
    flag=1
    for j in range(N):
        if j+i<N :
            
            if S[i+j]!=T[j]:
                flag=0
                break
    if flag==1:
            
        ans+=S[0:i]+T
        break
a=len(ans) if len(ans)!=0 else 2*N
print(a)

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

cw = 0
c = 1
while len(t) >= c:
    if s[len(s)-c:] == t[:c]:
        cw = c
    c += 1

print(max(n, len(s)+len(t)-cw))

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

ans = n * 2
chk = False

for i in range(n):
    j = 0
    while i+j < n:
        if s[i+j] == t[j]:
            ans -= 1
            j += 1
            chk = True
        else:
            ans = n * 2
            chk = False
            break
    if chk:
        break

print(ans)

Solution (Python):
n = int(input())
s = input()
t = input()
same = []
for i in range(n):
  if t[0:i+1] == s[len(s)-1-i:len(s)]:
    same.append(t[0:i+1])
if len(same) == 0:
  m = 0
else:
  m = len(same[len(same)-1])
print(len(s)+len(t)- m)

Solution (Python):
def solve(n, s, t):
    count = 0
    for i in range(n):
        if s[i:] == t[:n - i]:
            return 2 * n - (n - i)
    return 2 * n

_n = int(input())
_s = input()
_t = input()
print(solve(_n, _s, _t))

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

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

print(ans)

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

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

print(len(ans) if s != t else N)

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

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

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

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

for i in range(n):
  s_ = s[i:]
  t_ = t[:n-i]
  if s_ == t_:
    print(n+i)
    exit()
else:
  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*2 - (n-i))
        exit(0)
print(2*n)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
s, t = read().decode().split()

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

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
s, t = read().decode().split()

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

print(ans)

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

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

print(2*n)

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

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

Solution (Python):
import sys


def main():
    N = int(input())
    s = str(input())
    t = str(input())
    
    for i in range(N):
        if s[i] == t[0]:
            if s[i:] == t[:(N-i)]:
                print(len(s[:i]+s[i:]+t[(N-i):]))
                exit()
                
    print(len(s+t))

if __name__ == "__main__":
    main()

Solution (Python):

n = int(input())
s, t = input(), input()
a = -1
for i in range(n):
    if s[-i - 1 :] == t[: i + 1]:
        a = i
print(len(s) + len(t[a + 1 :]))

Solution (Python):
n = int(input())
s = list(input())
t = list(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()
for i in range(min(len(s), len(t)), -1, -1):
    if s[len(s) - i:] == t[:i]:
        print(len(s) + len(t) - i)
        break

Solution (Python):
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
s = ns()
t = ns()

ans = n * 2

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

ans -= c
print(ans)

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())
a=input()
b=input()
ans = N
for i in range(N):
    if a[i:] == b[:N-i]:
        break
    else:
        ans += 1
print(ans)

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
kaburi = 0
for i in range(n):
    if s[n-i-1:] == t[:i+1]:
        kaburi = max(i+1,kaburi)
print(n*2-kaburi)

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

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

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

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

Solution (Python):
from fractions import Fraction
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(N*2)

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

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