#include <stdio.h>

int try(long n, long div){
	return (n % div) ? (n % div == 1) : try(n/div, div);
}

int main(void){
	long n;
	int count = 0;

	scanf("%ld", &n);

	if(n > 100000) {
		for(long i=1; i*i <= n; i++) {
			if((n-1) % i == 0) {
				count++;
				if(i != (n-1) / i)
					count++;
			}
			if(n % i == 0) {
				if(i != 1 && try(n, i))
					count++;
				if(i != n / i && try(n, n/i))
					count++;
			}
		}
		count--;
	}else{
		for(int i=2; i <= n; i++) {
			if(try(n, i))
				count++;
		}
	}
	printf("%d", count);

	return 0;
}
