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):
def main():
    N = int(input())
    s = input()
    t = input()

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

if __name__ == '__main__':
    print(main())

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

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

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

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

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

    print(2*n-i)
    
if __name__ == "__main__":
    main()

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

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

Solution (Python):

import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, s: str, t: str):
    if t == s:
        print(N)
        return
    for i in range(1, N+1):
        S = s + t[-i:]
        if S[-N:] == t:
            print(len(S))
            break
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    s = next(tokens)  
    t = next(tokens)  
    solve(N, s, t)

if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):


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

def solve():
    for i in range(n):
        for j in range(n):
            if s[i]!=t[j]:continue
            m=s[i:]
            if m==t[:len(m)]:
                res=len(s[:i])+n
                return res
ans=solve()
if ans:print(ans)
else:print(2*n)

Solution (Python):
I=input;n,a,b=int(I()),I(),I();print(min([n+i for i in range(n)if a[i:]==b[:n-i]]+[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())

def output(i): 
    print (*s[:i], sep = '\n')
    print (*t, sep = '\n')
    return 

for i in range(N): 
    flag = True
    for j in range(N - i):
        if s[i + j] == t[j]:
            pass
        else:
            flag = False
    if flag == True:
        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):
    if s[-i-1:]==t[0:i+1]:
        ans=min(ans,2*n-i-1)
print(ans)

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

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

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

Solution (Python):
import sys, math, itertools, bisect, copy, re, heapq
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle






INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)








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

for i in range(N):
    
    
    
    ss = s[i:]
    tt = t[:N - i]
    if ss == tt:
        print(2 * N - (N - i))
        sys.exit()

print(2 * N)

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

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

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

Solution (Python):


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

s = list(s)
t = list(t)

s.reverse()

a1 = []
a2 = []

c1 = ""
c2 = ""

for i in range(n):
    c1 += s[i]
    c2 += t[i]
    temp = c1
    a1.append(temp[::-1])
    a2.append(c2)

max = 0
for i in range(n):
    if a1[i] == a2[i]:
        max = i+1




print(2*n-max)

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

ans = N

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

print(N + ans)

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

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


main()

Solution (Python):
a = int(input())
b = list(input())
c = list(input())
d = a * 2
for i in range(1, a + 1):
    bb = ""
    for j in range(a-i, a):
        bb += b[j]
    cc = ""
    for j in range(0, i):
        cc += c[j]
    if bb == cc:
        d = min(d, a * 2 - i)
print(d)

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

for i in range(n):
        if p[i:] == s[: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(2*N)

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

s = input()
t = input()

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

print(len(ans))

Solution (Python):

def main():
    n = int(input())
    S, T = tuple(input().rstrip() for _ in range(2))
    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):
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):
def main():
    N = int(input())
    s = input()
    t = input()
    for i in range(N):
        ok = True
        for j in range(N-i):
            if s[i+j] != t[j]:
                ok = False
                break
        if ok:
            print(i+N)
            return
    print(2*N)


if __name__ == "__main__":
    main()

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())


N = ii()
S = input()
T = input()

dupr = N
while(dupr>=0):
  if S[N-dupr:N] == T[0:dupr]:
    break
  else:
    dupr -= 1

print(N*2 - dupr)

Solution (Python):
a = int(input())
b = input()
c = input()
e = -1
for i in range(a):
    if b[-i-1:] == c[:i+1]:
        e = max(e,i)
if e == -1:
    print(len(b + c))
else:
    print(len(b + c[e+1:]))

Solution (Python):
n=int(input())
s=input()
t=input()
ans=[2*n]

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

print(min(ans))

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

p = 2*N
for i in range(N):
    if S[i:] == T[:N-i] and i+N < p:
        p = i + N

print(p)

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

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

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

if res == 0:
    print(len(s + t))
else:
    ans = s[:res] + t
    print(len(ans))

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

print(N*2)

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

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

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

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

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

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

tmp = s + t
for i in range(N):
    if s[i:] == t[:N-i]:
        tmp = s + t[N-i:]
        if len(tmp) < N:
            continue
print(len(tmp))

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

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
n=int(input())
s=input()
t=input()
cnt=0
for i in range(n):
    if s[i:]==t[:n-i]:
        print(len(s+t[n-i:]))
        sys.exit()
print(len(s+t))

Solution (Python):
from fractions import gcd
import math
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    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(n+i)
            return
    print(2*n)
main()

Solution (Python):
import numpy as np

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

moji = s
count = 0
while True:
    if moji[len(moji)-len(t)+count:] == t[0:len(t)-count]:
        moji += t[len(t)-count:]
        print(len(moji))
        break
    else:
        count += 1

Solution (Python):
def f(s, t):
    n = len(s)
    for i in range(n):
        if s[i:] == t[:n-i]:
            return len(s[:i] + t)
    return len(s + t)

def solve(n, s, t):
    return min(f(s, t), f(t, s))

n = 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]:
        tmp = len(s[i:])
        print(len(s + t[tmp:]))
        exit()

print(len(s + t))

Solution (Python):
n = int(input())
s = input()
t = input()
ans = float("inf")
for i in range(n + 1):
    a = s + t[i:]
    if a[:n] == s and a[-n:] == t:
        ans = min(ans, n * 2 - i)
print(ans)

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

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

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

print(len(s + t))

Solution (Python):
n=int(input())
s=input()
t=input()
ans=""
for i in range(n+1):
    s1=s[:n-i]
    s2=s[n-i:]
    t1=t[:i]
    t2=t[i:]
    if s2==t1:
        ans=s1+s2+t2
print(len(ans))

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

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

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

a = []

for i in range(n+1):
    a.append(s+t[n-i:])

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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
s = (stdin.readline().rstrip())
t = (stdin.readline().rstrip())
ans = len(s)
for i in range(N,0,-1):
    if list(s)[N-i:] == list(t)[:i]:
        break
    else:
        ans += 1
print(ans)

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

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

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

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

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

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

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

Solution (Python):
n = int(input())
s = input()
t = input()
i = 0
while i < n and s[i:] != t[:n - i]:
    i += 1
print(n + i)

Solution (Python):
string_len = int(input())
prefix = input()
suffix = input()
x = 0
for i in range(1,string_len + 1):
    if prefix[-i:] == suffix[:i]:
        x = i
print((2 * string_len) - x)

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

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

print(len(ans))

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

Solution (Python):
n = int(input())
a = str(input())
b = str(input())
ans = 0
for i in range(n):
    if a[i] == b[0]:
        if a[i:]==b[:(n-i)]:
            ans = len(a[i:])
            break
    if i == n-1 and a[i] == b[0]:
        ans = 1
print(2*n - ans)

Solution (Python):
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()



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

Solution (Python):
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()



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

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

"""
A - Prefix and Suffix
https://atcoder.jp/contests/agc006/tasks/agc006_a

"""
import sys


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


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


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

n = N
while 0 <= n:
    a = s[-(n+1):]
    b = t[0:n+1]
    if a == b:
        print(len(s+t[n+1:]))
        exit()
    n -= 1

print(len(s+t))
exit()

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

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

l = N  
while True:
    
    k = 2*N-l
    if k <= 0 or s[-k:] == t[:k]: break
    l += 1
print(l)

Solution (Python):
N=int(input())
s1=input()
s2=input()
l1=len(s1)
l2=len(s2)
ans=2*N

for i in range(l1):
    if s1[i:] == s2[:N-i] and ans > N+i:
        ans = N+i
print(ans)

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

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

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

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):
def solve():
    N = int(input())
    S, T = [input() for _ in range(2)]

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

    return 2 * N

print(solve())

Solution (Python):
def solve():
    N = int(input())
    S, T = [input() for _ in range(2)]

    i = 0
    while i < N:
        if S[i:] == T[:N - i]:
            break
        i += 1
    return (N + i)

print(solve())

Solution (Python):
N = int(input())
S, T = [input() for _ in range(2)]

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

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

Solution (Python):
n=int(input())
s=input()
t=input()
ans=0
for i in range(1,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):
    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()
start = max(0, len(s)-len(t))
def solve():
    for i in range(start,len(s)):
        for j in range(len(t)):
            if i+j >= len(s):
                return 2*N-(len(s)-i)
            if s[i+j] != t[j]:
                break
        else:
            return 2*N-(len(s)-i)
    return 2*N
print(solve())

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

def ok(n):
  for i in range(N - n):
    if s[i+n] != t[i]: return False
  return True

for i in range(N):
  if ok(i):
    print(2 * i + N - i)
    break
else: print(2 * N)

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

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

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

print(2*N-c)

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

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

Solution (Python):


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

for i in range(n):
    match = True
    for j in range(n):
        if i + j < n:
            if s[i + j] != t[j]:
                match = False
    if match:
        if i == 0:
            print(n)
        else:
            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:n] == t[0:n-i]:
        print(2*n - (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 = 0
for i in range(1,N+1):
    if s[-i:] == t[:i]:
        ans = i

print(2*N - ans)

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

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

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

print(ans)

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

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

print(ans)

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

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

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

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

print(2*N-dup)

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

Solution (Python):
n = int(input())
s = input().strip()
t = input().strip()
is_match = False
for i in range(len(s)):
  if s[i:] == t[:n-i]:
    is_match = True
    break
if is_match:
  print(len(s[:i] + t))
else:
  print(len(s + t))

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

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

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

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

Solution (Python):
I=input;n=i=int(I());s,t=I(),I();j=0;exec('j=max(i*(s[-i:]==t[:i]),j);i-=1;'*n);print(2*n-j)

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

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

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

Solution (Python):

'''
問題
文字列s, tが与えられる
長さN以上で, 先頭N文字がsに一致し, 末尾N文字がtに一致するような文字列として可能なものの最小の長さは？

考察
sとtが完全に等しければ答えはN
sとtが完全に違っていれば答えは2*N
sの最後の文字とtの最初の文字が同じで,sの最後から2番目の文字とtの最初から2番目の文字が違っていれば答えは2*N-1

sの最後の文字とtの最初から2文字目の文字が同じで
sの最後から2番目の文字とtの最初の文字が同じなら
答えは2*N-1

sの最後から1番目の文字とtの最初からi文字目が同じで
sの最後から2番目の文字とtの最初からi-1文字目が同じで
...
sの最後からi番目の文字とtの最初から1文字目が同じなら
答えは2*N-i

Nは1以上100以下
計算量はO(N**2)
最小の文字列の長さを求めたいのでiはNからはじめて1ずつ減らしていき条件が最初に満たされたときのiを答えとする
'''

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

m = 0

for i in range(N,0,-1): 
	unity = True
	for j in range(i):
		
		if s[-(j+1)] == t[i-j-1]:
			continue
		else:
			unity = False
	
	if unity:
		m = i
		break
	
print(str(2*N-m))

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

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

co = 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

count = n

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

print(count)

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

for i in range(n):

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

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

for i in range(n):
  flag = True
  for j in range(0,n-i):
    if s[i+j] != t[j]:
      flag = False
  if flag:
    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] or t[i:] == s[:N-1]:
        print(N +  i)
        exit()

print(2*N)

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

res = 2* N
k = 0
a = 0
for i in range(N):
    flag = True
    tmp = 0
    for j in range(N-i):
        if s[i+j] == t[j] and flag == True:
            tmp += 1
        else:
            flag = False
    a = max(a, tmp)

        
print(res - a)

Solution (Python):


import sys

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    s, t = SI(), SI()

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


print(main())

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

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

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

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

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

Solution (Python):
n=int(input())
A=input()
B=input()
s=0

ans=n
D=[i for i in range(n)][::-1]
for i in D:
  if A[-i-1:]==B[:i+1]:
    
    print(ans)
    exit()
  else:
    ans+=1
print(ans)