program fm
    implicit none
    integer(16)::N,m
    integer::cnt=2
    integer(16)::i,j
    read*,N
    do i=2,int(sqrt(real(N)))
      if(mod(N,i)==0)then
        m=N/i
        do while(mod(m,i)==0)
          m=m/i
        end do
        if(mod(m,i)==1)cnt=cnt+1
      endif
    end do
    do i=2,int(sqrt(real(N-1)))
      if(mod(N-1,i)==0)cnt=cnt+1+merge(0,1,i==(N-1)/i)
    end do
    print"(I0)",cnt-merge(1,0,N==2)
end program fm