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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		long n = fs.nextLong();
		
		if(n == 2){
			System.out.println(1);
			return;
		}
		
		long ans = 0;
		long sub1 = n - 1;
		
		ArrayList<Long> yakusuuList = yakusuu(sub1);
		HashSet<Long> yakusuuSet = new HashSet<Long>(yakusuuList);
		ans+=yakusuuList.size();
		yakusuuList = yakusuu(n);
		for(Long longVal : yakusuuList){
			long nCopy = n;
			while(nCopy % longVal == 0){
				nCopy = nCopy / longVal;
			}
			
			if(nCopy % longVal == 1){
				yakusuuSet.add(longVal);
//				ans++;
			}
		}
		System.out.println(yakusuuSet.size()+2);
	}
	
	ArrayList<Long> yakusuu(long n){
		ArrayList<Long> ret = new ArrayList<>();
		for(long i = 2; i*i <= n; i++){
			if(n % i == 0){
				ret.add(new Long(i));
				ret.add(new Long(n/i));
			}
		}
		return ret;
	}

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}
