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))
      breakn = 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