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

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

print(n * 2)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    x = 0
    for i in range(N):
        if S[i:] == T[:N - i]:
            x = N - i
            break

    print(N * 2 - x)


    

if __name__ == '__main__':
    main()

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

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

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

ind = 0
mx = min(len(s), len(t))
mx_len = 0
while ind < mx:
    pre_i = s[-(ind + 1):]
    suf_i = t[:(ind + 1)]
    if pre_i == suf_i:
        mx_len = ind + 1

    ind += 1

ans = len(s) + len(t) - mx_len
print(ans)

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

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

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

if s == t:
    print(N)
else:
    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()

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

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

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

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

Solution (Python):

import collections
import itertools as it
import math

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






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

Solution (Python):


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


ans = S + T
end = N
for i in range(N):
    if S[i:] == T[:end]:
        ans = S + T[end:]
        break

    end -= 1

print(len(ans))

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

if S == T:
    print(N)
    exit()
for i in reversed(range(N)):
    if S[N-i-1:] == T[:i+1]:
        print(2*N - i - 1)
        exit()
    else:
        continue

print(2*N)

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(2 * i + (N - i))

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

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

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

print(N * 2 - cnt)

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

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

print(u+n)

Solution (Python):
N = int(input())
S = input()
T = input()
kaburi = 0
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()
kaburi = 0
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()
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):
def main():
    N = int(input())
    s = list(input())
    t = list(input())

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
N = I()
s,t = S(),S()
ans = 2*N
for i in range(N,0,-1):
    if s[-i:]==t[:i]:
        ans -= i
        break
print(ans)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
N = I()
s,t = S(),S()
ans = 2*N
minus = 0
for i in range(1,N+1):
    if s[-i:]==t[:i]:
        minus = max(minus,i)
print(ans-minus)

Solution (Python):
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
N = I()
s,t = S(),S()
ans = 2*N
minus = 0
for i in range(1,N+1):
    if s[-i:]==t[:i]:
        minus = max(minus,i)
print(ans-minus)

Solution (Python):
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
N = I()
s,t = S(),S()
ans = len(s)+len(t)
t_accumulate = list(itertools.accumulate(t))
for x in t_accumulate[::-1]:
    if x in s:
        ans -= len(x)
        break
print(ans)

Solution (Python):
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
N = I()
s,t = S(),S()
ans = len(s)+len(t)
t_accumulate = list(itertools.accumulate(t))
for x in t_accumulate[::-1]:
    if x in s:
        ans -= len(x)
        break
if ans>=N:
    print(ans)
else:
    print(max(N,len(s)+len(t)))

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

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

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

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

print(N * 2)

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

Solution (Python):
import sys
N=int(input())
A=input()
B=input()
for i in range(N+1):
  if A[i:N]==B[0:N-i]:
    print(N+i)
    sys.exit()

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 = str(input())
T = str(input())

res = 0
for i in range(N):
    if S[i:] == T[:N-i]:
        res = N-i
        break

print(2 * N - res)

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

Solution (Python):
N = int(input())
s = list(input())
t = list(input())
N2 = N * 2
ans = 0
for i in range(N):
    temp = 0
    ns = s[i:]
    for j, k in zip(ns, t):
        if j == k:
            temp += 1
        else:
            break
    else:
        ans = max(ans, temp)

print(N2 - ans)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=ST()
    T=ST()
    ans = 2*N
    for i in range(1,N+1): 
        if(S[-i:] == T[:i]):
            ans = min(ans, 2*N-i)
    print(ans)
if __name__ == '__main__':
    main()

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

if t in s:
  print(N)
  quit()

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

Solution (Python):

n = int(input())
s = input()
t = input()
ans = n * 2
for i in range(n):
    flag = True
    for j in range(n - i):
        if s[i + j] != t[j]:
            flag = False
            break
    
    if flag:
        print(ans - (n - i))
        exit()

print(ans)

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

ans = N + N
for i in range(N):
  w = S + T[-(i+1):]
  if w[:N] == S and w[-N:] == T:
    ans = min(ans,i+N+1)

if S == T:
  ans = N
    
print(ans)

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

s = input()
t = input()

i = 0

while i < N:
    if s[i:] == t[:N-i]:
        break
    else:
        i+=1

print(N+i)

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

Solution (Python):

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

print(N+i)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    

    
    

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

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
s = input()
t = input()
l = 2*N
kouho = []

for i in range(N):
    ns = s[i:]
    res = 0
    for j, k in zip(ns, t):
        if j == k:
            res += 1
        else:
            break
    kouho.append(res)

print(l - max(kouho))

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

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

Solution (Python):
N = int(input())
S = input()
T = input()
if S == T:
    print(len(S))
    exit()
for i in range(len(T)):
    tmp = S+''.join(T[-i-1:])
    if tmp[i+1:] == T:
        print(len(tmp))
        exit()

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

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

print(N + cnt)

Solution (Python):
N = int(input())
s = input()[::-1]
T = list(input()[::-1])

index = len(T)
for i, t in enumerate(T):
    if t == s[0]:
        j = 0
        while j < len(T) - i:
            if s[j] != T[i + j]:
                break
            j += 1
        else:
            index = i
            break

res = s[::-1] + "".join((T[:index])[::-1])
print(len(res))

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

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

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

print(len(ans))

Solution (Python):

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

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

Solution (Python):
N=int(input())
s=str(input())
t=str(input())
c=0
tmp=0
S=list(s)
T=list(t)
for i in range(N):
    if s[N-i-1:N]==t[0:i+1]:
        c=i+1
    

print(2*N-c)

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

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

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

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

print(2*N-temp)

Solution (Python):


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

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

print(N+delta)

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

answer = 2*N

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

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

Solution (Python):

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

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

print(2*N - max)

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

Solution (Python):

"""
Created on Sun May 10 17:43:29 2020

@author: shinba
"""

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

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

print(2*n-l)

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

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

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

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

else:
  print(2*n)

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

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

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

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

if len(s)+len(t)<= n:
  print(n)
  exit()
  
dup = min(len(s)+ len(t)-n, len(s), len(t))
for i in range(dup, 0 , -1):
  if s[-i:] == t[:i]:
    print(len(t)+len(s) - i)
    break
else:
  print(len(s)+len(t))

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

s1=list(input())

s2=list(input())

ans = n*2

flag = False

for i in range(n):
    for j in range(n):
        if s1[i:n]==s2[j:n-i]:
            ans -= len(s1[i:n])
            flag = True
            break
    if flag:
        break

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    s = input().rstrip('\n')
    t = input().rstrip('\n')
    for i in range(n):
        if s[i:] == t[:n-i]:
            print(n+i)
            break
    else:
        print(n*2)
        
if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

def checkSpell(s, t):
    return s == t

def main():
    n = int(input())
    s = input()
    t = input()
    for i in range(n):
        ans = 0
        for j in range(n):
            if s[i] == t[j]:
                while checkSpell(s[i], t[j]):
                    ans += 1
                    i += 1
                    j += 1
                    if i == n or j == n:
                        print(n*2 - ans)
                        sys.exit()
    print(n*2)

if __name__ == '__main__':
    main()

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

n_s=len(s)
n_t=len(t)
l=[]
for i in range(n_s):
    for j in range(n_t):
        l.append(s[:i]+t[j:])
ans=s+t
for c in l:
    if c[:n_s]==s and c[len(c)-n_t:]==t:
        if len(ans)>len(c):
            ans=c

print(len(ans))

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

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

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

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

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

main()

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

Solution (Python):






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





for i in range(len(s)):

    if s[i:] == t[:len(t)-i]:

        print(i+N)
        break
    elif i == len(s)-1:

        print(2*N)

Solution (Python):
def main():
    N = int(input())
    s = input()
    t = input()
    ss = tt = ''
    l = 0
    for i in range(N):
        ss = s[-1-i] + ss
        tt = tt + t[i]
        if ss == tt:
            l = len(ss)
    print(2 * N - l)
    return

if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    s = input()
    t = input()

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

if __name__ == "__main__":
    resolve()

Solution (Python):
N = int(input())
s = input()
t = input()
index = 0
for i in s:
    if i == t[index]:
        index += 1
    else:
        continue
print(len(s + t[index:]))

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


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

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


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
S1 = input()
S2 = input()
ans = 2 * n
for i in range(1,n + 1):
    if S1[n - i:] == S2[:i]:
        ans = min((n - i) * 2 + i,ans)
print(ans)

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


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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    S = input()
    T = input()
    ans = N*2
    for i in range(N):
        s = S[i:]
        t = T[:N-i]
        if s == t:
            ans -= N-i
            break
    print(ans)

if __name__ == '__main__':
    main()

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()
  else:
    ans += 1
  
print(ans)

Solution (Python):



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


ans_str = 't'*3*N


for i in range(N+1):
    is_ok = True
    tmp_str = ['']*2*N
    for j in range(N):
        tmp_str[j] = s[j]
    for j in range(N):
        if tmp_str[i+j]=='':
            tmp_str[i+j] = t[j]
        elif not tmp_str[i+j]==t[j]:
            is_ok = False
            break
    if is_ok:
        if len(tmp_str)<len(ans_str):
            ans_str = "".join(tmp_str)


print(len(ans_str))

Solution (Python):
import math
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
v = sys.stdin.readline().rstrip()



ans = 0

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

print(n * 2 - ans)

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

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

print(r)

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

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

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

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

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

print(2*n)

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

Solution (Python):
def main():
    N = int( input())
    s = input()
    t = input()
    for i in range(N):
        check = True
        for j in range(N-i):
            if not s[i+j]  == t[j]:
                check = False
                break
        if check:
            print(i+N)
            return
    print(N*2)
if __name__ == '__main__':
    main()

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

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

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

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

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

maxl = 0
for i in range(n):
	sub_s = s[n-i-1:]
	sub_t = t[:i+1]
	if sub_s == sub_t:
		maxl = max(maxl, i + 1)

print(2 * n - maxl)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


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 lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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

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

count = 0
for i in range(len(s)):
    if s[i:] != (t[:~i+1] if i > 0 else t):
        count += 1
    else:
        break

print(n + count)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    res = n
    for i in range(n):
        for j in range(n):
            if i + j < n:
                if s[i + j] != t[j]:
                    break
        else:
            res = i
            break

    print(res + n)


if __name__ == '__main__':
    resolve()

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

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

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

print(2*n - same)

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

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):
def myAnswer(N:int,s:str,t:str) -> int:
   if(s == t): return N
   if(N == 1): return 2
   total = N * 2
   
   for i in range(N):
      if(s[i:] == t[:N-i]):
         total -= len(s[i:])
         break
   return total

def modelAnswer():
   return
def main():
   N = int(input())
   s = input()
   t = input()
   print(myAnswer(N,s,t))
if __name__ == '__main__':
   main()

Solution (Python):
















N = int(input())
S = input()
T = input()
ans = 2*N
for i in range(N,-1,-1):
    ST = S[:i] + T
    
    if ST[:N]==S and ST[-N:]==T:
        ans = min(len(ST),ans)

print(ans)

Solution (Python):

def myAnswer(N:int,s:str,t:str) -> int:
   if(s == t): return N
   if(N == 1): return 2
   total = N * 2
   for i in range(N):
      counter = 0
      n = i
      for j in range(N-i):
         
         if(s[n] == t[j]):
            n += 1
            counter += 1
         else:
            break
      else:
         total -= counter
         break
   return total

def modelAnswer():
   return
def main():
   N = int(input())
   s = input()
   t = input()
   print(myAnswer(N,s,t))
if __name__ == '__main__':
   main()

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