#include <stdio.h>

int main(void){
	long n, temp;
	long div[1000] = {0};
	int idx = 0, count = 0;

	scanf("%ld", &n);

	for(long i=1; i*i <= n-1; i++) {
		if((n-1) % i == 0) {
			count++;
			if(i != (n-1) / i)
				count++;
		}

		if(n % i == 0) {
			div[idx++] = i;
			if(i != n / i) {
				div[idx++] = n / i;
			}
		}
	}
	count--;

	for(int i=1; i < idx; i++) {
		temp = n;
		while(temp >= div[i]) {
			if(n % div[i] == 0) {
				temp /= div[i];
			}else{
				temp -= div[i];
			}
		}
		if(temp == 1)
			count++;
	}
	printf("%d", count);

	return 0;
}
