program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,overlap
    character(:),allocatable:: s,t

    read*, n
    allocate(character(n):: s,t)
    read*, s
    read*, t

    overlap=0
    do i=n-1,0,-1
        if (s(n-i:n) == t(1:1+i)) then
            print'(i0)', 2*n-(i+1)
            stop
        end if
    end do
    print'(i0)', 2*n
end program name