program division_or_substraction
  implicit none
  integer(8) :: n, r, k, x = 2_8
  read(*,*) n
  if (n == 2_8) then
    write(*,'(i0)') 1
    stop
  end if
  r = sqrt(real(n,8)+0.5d0)
  do k = 2_8, r
    if (ok(n,k)) then
      x = x+1_8
    else
      if (mod(n-1_8,k) == 0_8) x = x+1_8
      if (k*k /= n-1_8) x = x+1_8
    end if
  end do
  write(*,'(i0)') x
contains
  logical function ok(n,k)
    integer(8), intent(in) :: n, k
    integer(8) :: m
    m = n
    do while (m >= k)
      if (mod(m,k) == 0) then
        m = m/k
      else
        m = mod(m,k)
      end if
    end do
    ok = m == 1
  end
end program division_or_substraction