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 = str(input())
t = str(input())
I = []
for i in range(len(s)+1):
    if s[len(s)-i:len(s)] == t[0:i]:
        I.append(i)
s = s[0:len(s)-max(I)]
print(len(s+t))

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

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

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

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

Solution (Python):
import os
import math
import itertools
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

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

while(True):
    try:
        n = get_int()
        s, t = [input() for _ in range(2)]
        for i in range(n + 1):
            if s[i:] == t[:n - i]:
                print(n + i)
                exit()
    except EOFError:
        exit()

Solution (Python):
import os
import math
import itertools
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

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

while(True):
    try:
        n = get_int()
        s, t = [input() for _ in range(2)]
        for i in range(len(s)):
            if s[i:] == t[:len(s) - i]:
                print(len(s) + i)
                exit()
        print(len(s + t))
    except EOFError:
        exit()

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

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

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

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

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

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

Solution (Python):

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

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

Solution (Python):

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

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

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**7) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

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

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

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

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

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

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

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

Solution (Python):


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

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

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

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

Solution (Python):
def a():return input()
def ai():return int(input())
def ma():return map(int, input().split())
def ms():return map(str, input().split())
def lma():return list(map(int, input().split()))
def lms():return list(map(str, input().split()))
k= []
l = []
f = 0
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")

n = ai()
a = input()
b = input()
c =a
e = n
for i in range(n):
   
    if b[:n-i] == c[i:]:break
    else:e-=1
print(n*2-e)

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

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

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

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

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

s = input()
t = input()

c = N

for i in range(N):
    f = 1
    for j in range(N-i):
        if not s[i+j]==t[j]:
            f = -1
    if f>0:
        K = c
        break
    else:
        c = c-1
else:
    K=0

print(2*N-K)

Solution (Python):
import re

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

answer=N

for i in range(N):
  if re.match(s[i:],t):
    print(answer+i)
    exit()
print(2*N)

Solution (Python):


import re

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

idx = 0

for i in range(len(s)-1, -1, -1):
    if re.match(s[i:], t):
        matchOB = s[i:]
        idx = len(matchOB)
        
print(len(s + t[idx:]))

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

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

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

print(ans)

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    s = input_raw[0]
    input_raw = read_func().strip().split()
    t = input_raw[0]

    for i in range(N):
        all_ok = True
        for j in range(N):
            if i + j < N:
                if s[i + j] != t[j]:
                    all_ok = False
                    break
        if all_ok == True:
            break

    if all_ok == True:
        print N + i
    else:
        print N + i + 1


if __name__ == '__main__':
    main()

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

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

Solution (Python):

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

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

Solution (Python):

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

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

Solution (Python):



def main():
    """Function."""
    n = int(input())
    s = str(input())
    t = str(input())

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

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


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

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

for k in reversed(range(1, N + 1)):
    if Ss[-k:] == Ts[:k]:
        print(2 * N - k)
        break
else:
    print(2 * N)

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

cnt = 0
for i in range(N):
    if s[i]==t[0]:
        for j in range(N):
            if s[i+j]!=t[j]:
                break
            if i+j>=N-1:
                cnt = max(cnt, j+1)
                break
ans = N+N-cnt
print(ans)

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

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

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

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

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

print(ans)

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

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

res = 0
for i in range(n):
    r = 0
    c = 0
    for j in range(n-i):
        if s[i+j] == t[j] and c == 0:
            r += 1
        else:
            c = 1
    if r == n-i:
        res = n+i
        break

if res == 0:
    res = 2*n
print(res)

Solution (Python):

import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


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

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

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

Solution (Python):
import sys


def main() -> None:
    n = int(next_str())
    s = next_str()
    t = next_str()

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

    print(2 * n - overlap)


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Solution (Python):
import sys


def main() -> None:
    n = int(next_str())
    s = next_str()
    t = next_str()

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


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

S = s + t
r = len(S)
for i in range(N):
    ti = t[:(N-i)]
    index = s.find(ti)
    if index > -1:
        print(len(s)+len(t) - (len(s)-index))
        exit()
print(r)

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

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

s = input()
t = input()
ans = n
flag = 1
for i in range(n):
    f = 1
    for j in range(n-i):
        if s[i+j] != t[j]:
            f = 0
            break
    if f == 1:
        ans += i
        flag = 0
        break
        
if flag == 1:
    ans += n
print(ans)

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

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

x = 0

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

print(N + x)

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

for i in range(N):
  j = 0
  fl = True
  while j+i < N:
    if S[i+j] == T[j]:
      j += 1
      
    else:
      fl = False
      break
      
  if(fl):
    print(N+i)
    exit(0)
    
print(2*N)

Solution (Python):
N = int(input())
S = list(input())
T = list(input())
counter = 0
for i in range(N) :
    if S == T :
        print(N+counter)
        break
    else :
        S.pop(0)
        T.pop(-1)
        counter += 1
        if len(S) == 0 :
            print(2*N)

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

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

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

Solution (Python):
n = int(input())
listS = list(input())
listT = list(input())

if listS == listT:
    print(len(listS))

else:
    count = len(listS)+ len(listT)
    index1 = 0
    while index1 < len(listS):
        if listS[index1] == listT[0]:
            index2 = 0
            while index2 < len(listS)-index1:
                if listS[index1+index2] == listT[index2]:
                    index2+=1
                else:
                    break
            if index2 == len(listS)-index1:
                count-=(len(listS)-index1)
                print(count)
                break
            else:
                index1+=1
        else:
            index1+=1
    if index1 == len(listS):
        print(count)

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
s = input().strip()
t = input().strip()
 
i = N
while True:
    u = t[i:]
    ans = s+u
    if ans[-N:] == t:
        print(len(ans))
        break
    i -= 1

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


nomatch = False
place = 0
for i in range(N):
    place = i
    if t[0] == s[i]:      
        match = True
        for j in range(N-i):
            if t[j] != s[i+j]:
                match = False
        if match:
            break
        else:
            continue
    elif i == N-1:
        nomatch = True

if nomatch:
    print(2*N)
else:
    print(N+place)

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

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

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

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

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

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

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

sl = list(s)
tl = list(t)

ans = s + t
for i in range(n):

    if s[i:] == t[:n-i]:     
        sp = s[:i]
        common = s[i:]
        tp = t[n-i:]
        ans = sp + common + tp
        
        break

        
print(len(ans))

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

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

print(solve())

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

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

Solution (Python):
N=int(input())
a=input()
b=input()
d=0
for i in range(1,N+1):
    at=a[-i:]
    bt=b[:i]
    if(at==bt):
        d=i
print(2*N-d)

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

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

r = N
while 1:
    s, t = S[N - r:], T[:r]
    
    if s == t:
        break
    r -= 1

result = N * 2 - r
print(result)

Solution (Python):
'''
最短でans == s == t
最長でans == (s + t)
'''
n = int(input())
s = input()
t = input()

ans = s
i = 0
while True:
    if ans[(-1) * n:] == t:
        break
    else:
        ans = s + t[(-1) * (i+1):]
        i += 1
        if i == n:
            break
print(len(ans))

Solution (Python):
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
from random import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
s = input()
t = input()

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

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

res = s+t
for num in reversed(range(n)):
    tmp = s[:num]+t
    if tmp[:n] == s and tmp[-n:] == t:
        res = tmp
print(len(res))

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

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

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

if ans == []:
	print(2 * n)
else:
	print(2 * n - max(ans))

Solution (Python):
n = int(input())
S1 = input().rstrip()
S2 = input().rstrip()
for i in range(n,-1,-1):
    if S1[n-i:] == S2[:i]:
        print(len(S1+S2[i:]))
        break

Solution (Python):
N = int(input())
s = input()
t = input()
ans = ''
for i in range(N):
    prefix = s[i:]
    if t.startswith(prefix):
        ans = s[:i] + t
        break
if ans == '':
    ans = s + t
print(len(ans))

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

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

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

Solution (Python):






if __name__ == '__main__':
    n = int(input())
    s = input()
    t = input()

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

        if s_end == t_start:
            print(len(s) + len(t) - len(s_end))
            exit()

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

Solution (Python):
n = int(raw_input())
a = raw_input()
b = raw_input()
cur = n*2

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

print(cur)

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

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

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

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

Solution (Python):
def sarch(n, S, T, i):
    if S[n - i:] == T[0:i]:
        i
    else:
        i = sarch(n, S, T, i - 1)
    return i

N = int(input())
s = input()
t = input()
print(N * 2 - sarch(N, s, t, N))

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

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

print(ans)

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

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

print(n*2-ans)

Solution (Python):
n=int(input())
s=list(input())
t=list(input())
t.reverse()
ans=float("inf")
if s==t:
    print(n)
    exit()
else:
    for i in range(n):
        a=t[i:]
        a.reverse()
        if s[i:]==a:
            ans=i
    if ans==float("inf"):
        print(2*n)
        exit()
    del s[ans:]
    print(len(s+t))

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

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

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

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

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

Solution (Python):


import sys, math, copy




HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    s = input()
    t = input()
    max_common = 0
    for i in range(1, n + 1):
        s_tail = s[-i:]
        t_head = t[:i]
        if s_tail == t_head:
            max_common = i
    print(2 * n - max_common)

main()

Solution (Python):



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

res=len(s)
while(len(s)>0):
  if s==t:
    break
  else:
    res=res+1
    s=s[1:]
    t=t[:-1]
print(res)

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

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

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

print(ans)

Solution (Python):
def main():
    """最長: s + t

    abc
      abc

    abc
     abc

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

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

    print(len(ans))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys


n=int(input())
s=input()
t=input()
test=s+t
if(s==t):
    print(len(s))
    sys.exit()
for i in range(1,n+1)[::-1]:
    test=s[0:-i]+t
    if(test[:n]==s and test[-n:]==t):
        print(len(test))
        sys.exit()
        
print(len(s+t))

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

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

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

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

Solution (Python):
n, s, t = [input().strip() for _ in range(3)]
n = int(n)
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)
        break
else:
    print(2 * n)

Solution (Python):
def minimumLen(s, t):
    n = len(s)
    failed = [-1 for i in xrange(n)]
    pos = -1
    for i in xrange(1, n):
        while pos!=-1 and t[pos+1]!=t[i]:
            pos = failed[pos]
        if t[pos+1]==t[i]:
            pos += 1
        failed[i] = pos
    pos = -1
    for c in s:
        while pos!=-1 and t[pos+1]!=c:
            pos = failed[pos]
        if t[pos+1]==c:
            pos += 1
    return n*2-(pos+1)

def main():
    n = int(raw_input().strip())
    s = raw_input().strip()
    t = raw_input().strip()
    print minimumLen(s, t)

if __name__ == '__main__':
    main()

Solution (Python):
class KMP:
    pattern = None
    length = -1
    failed = None
    def __init__(self, pattern):
        self.pattern = pattern
        self.length = len(pattern)
        self.failed = [-1 for i in xrange(self.length)]
        for i in xrange(1, self.length):
            prev = self.failed[i-1]
            while prev!=-1 and pattern[prev+1]!=pattern[i]:
                prev = self.failed[prev]
            if pattern[prev+1]==pattern[i]:
                prev += 1
            self.failed[i] = prev

def minimumLen(s, t):
    kmp = KMP(t)
    offset = -1
    for c in s:
        while offset!=-1 and kmp.pattern[offset+1]!=c:
            offset = kmp.failed[offset]
        if kmp.pattern[offset+1]==c:
            offset += 1
    return len(s)+len(t)-(offset+1)

def main():
    n = int(raw_input().strip())
    s = raw_input().strip()
    t = raw_input().strip()
    print minimumLen(s, t)

if __name__ == '__main__':
    main()

Solution (Python):
class KMP:
    pattern = None
    length = -1
    failed = None
    def __init__(self, pattern):
        self.pattern = pattern
        self.length = len(pattern)
        self.failed = [-1 for i in xrange(self.length)]
        for i in xrange(1, self.length):
            prev = self.failed[i-1]
            while prev!=-1 and pattern[prev+1]!=pattern[i]:
                prev = self.failed[prev]
            if pattern[prev+1]==pattern[i]:
                prev += 1
            self.failed[i] = prev

def minimumLen(s, t):
    kmp = KMP(t)
    offset = -1
    for c in s:
        while offset!=-1 and kmp.pattern[offset+1]!=c:
            offset = kmp.failed[offset]
        if kmp.pattern[offset+1]==c:
            offset += 1
    return len(s)+len(t)-(offset+1)

def main():
    n = int(raw_input().strip())
    s = raw_input().strip()
    t = raw_input().strip()
    print minimumLen(s, t)

if __name__ == '__main__':
    main()