local n = io.read("*n", "*l")
local s = io.read()
local t = io.read()
local pos = n + 1
for i = 1, n do
  local same = true
  for j = i, n do
    if(s:sub(j, j) ~= t:sub(j - i + 1, j - i + 1)) then
      same = false
      break
    end
  end
  if same then
    pos = i
    break
  end
end
print(n + pos - 1)
