      MODULE divisorMod
      IMPLICIT NONE
      
      contains
      function allDivisor( N ) result( resArray )
        implicit none
        integer(16),intent(in) :: N
        integer(16),allocatable :: resArray(:),buffer(:)
        integer(16) :: i,c
        
        !N must be N>=1
        !resArray must be deallocated
        
        allocate( buffer(floor(sqrt(real(N)))*2) )
        
        !c : counter
        c = 1
        do i = 1,floor(sqrt(real(N+1)))
          if( mod(N,i)==0 )then
            buffer(c) = i
            c = c + 1
          end if
        end do
        
        !c is allways over 1
        c = c - 1
        
        
        if( buffer(c)*buffer(c)==N )then
          !n is Square number
          buffer(c:2*c-1) = N / buffer(c:1:-1)
          c = 2*c - 1
        else
          buffer(c+1:2*c) = N / buffer(c:1:-1)
          c = 2*c
        end if
        
        !c is now number of divisor
        allocate( resArray(1:c) )
        resArray(1:c) = buffer(1:c)
      end function allDivisor
      END MODULE divisorMod


      PROGRAM divisionOrSubtraction
      use divisorMod
      IMPLICIT NONE
      integer(16) :: ans,n,k,sz,i,m
      integer(16),allocatable :: divisor(:)
      
      read*,n
      
      !case: only subtraction
      ans = size( allDivisor(n-1) )
      !divisor 1 would be excepted
      ans = ans - 1
      
      divisor = allDivisor( n )
      sz = size( divisor )
      
      !for all divisors
      do i = 2,sz
      m = n
        do while(.true.)
          
          if( mod( m,divisor(i) )==0 )then
            m = m / divisor(i)
            
          else
            exit
          end if
          
        end do
        if( mod(m,divisor(i))==1 ) ans = ans + 1
      end do
      
      print*,ans
      
      
      END PROGRAM