program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,m,n
    
  
    read(*,*) n
    read(*,*)s
    read(*,*)t
    
    do i=1,n,-1
        if(s(n+1-i:n) .ne. t(1:i))then
            m=2*n-i+1
            write(*,*) m
            stop
        end if
    enddo
    write(*,*) n
  
    stop
end program sample
  

