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.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long n = scanner.nextLong();

        if (n == 2) {
            System.out.println(1);
            return;
        }

        final long sqrt = (long) Math.sqrt(n);
        final Map<Long, Long> primes = primeFactorization(n - 1);
        long counter = 1; // none
        for (final long value : primes.values()) {
            counter *= value + 1;
        } // 約数の全ての組み合わせ(1含む)
        if (!primes.containsKey(2L)) {
            counter++; // 2 は必ず答えに含まれるので，約数になければ追加
        }
        if (isPrimeNumber(n - 1) && !primes.containsKey(n - 1)) {
            counter++;
        }

        for (long i = 3; i <= sqrt; i++) {
            if (n % i != 0) {
                continue;
            }

            long tmp = n / i;
            while (tmp % i == 0) {
                tmp /= i;
            }
            if (tmp % i == 1) {
                counter++;
            }
        }

        System.out.println(counter);
    }

    private static Map<Long, Long> primeFactorization(long n) {
        final double sqrt = Math.sqrt(n);
        final Map<Long, Long> countMap = new HashMap<>();
        for (long i = 2; i <= sqrt; i++) {
            if (n % i == 0) {
                countMap.compute(i, (k, v) -> v = v == null ? 1 : v + 1);
                n /= i;
                i--;
            }
        }

        if (n != 1) {
            countMap.compute(n, (k, v) -> v = v == null ? 1 : v + 1);
        }

        return countMap;
    }

    private static boolean isPrimeNumber(final long n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}
