program main
  implicit none
  integer*8::N,upper,i,j
  read *,N
  upper = INT(SQRT(DBLE(N)+1))

  if(MOD(N,3).eq.0) then
     print '(a)',"3"
     return
  else if(MOD(N,4).eq.0) then
     print '(a)',"4"
     return
  end if

  if(MOD(N,2).eq.0) N = N/2
  do i=5,upper,2
     if(MOD(N,i).eq.0) then
        print '(i0)',i
        return
     end if
  end do
  print '(i0)',N
end program main