Given is a positive integer N.

We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.

* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.



In how many choices of K will N become 1 in the end?

Constraints

* 2 \leq N \leq 10^{12}
* N is an integer.

Input

Input is given from Standard Input in the following format:


N


Output

Print the number of choices of K in which N becomes 1 in the end.

Examples

Input

6


Output

3


Input

3141


Output

13


Input

314159265358


Output

9
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a[]= {0,-1,0,1};
	static int b[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		long vv=sc.nextLong();


		ArrayList<Long> cc = new ArrayList<>();
		for(long i=1;Math.pow(i,2)<=vv;i++) {
			if(vv%i==0) {
				if(i!=1)cc.add(i);
				if(vv/i!=i)cc.add(vv/i);
			}
		}
		
		for(long i=1;Math.pow(i, 2)<=vv-1;i++) {
			if((vv-1)%i==0) {
				if(i!=1)cc.add(i);
				if((vv-1)/i!=i)cc.add((vv-1)/i);
			}
		}
		Collections.sort(cc);
		int ctn=0;
		for(long i:cc) {
			long v=vv;
			while(v%i==0) {
				v=v/i;
			}
			if(v%i==1) {
				ctn++;
			}
		}
		p(ctn);
	}
	

	

	
	
	
}
