using System;
using System.Linq;
using System.Collections.Generic;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC161.F();
            //ABC161.F_X();
        }

        class ABC161
        {
            public static void A()
            {
                var X = Read.Int();
                var Y = Read.Int();
                var Z = Read.Int();
                Console.WriteLine("{0} {1} {2}", Z, X, Y);
            }
            public static void B()
            {
                var N = Read.Int();
                var M = Read.Int();
                var A = Read.IntN();
                Array.Sort(A);
                var total = A.Sum();
                Console.WriteLine(A[N - M] * 4 * M < total ? "No" : "Yes");
            }
            public static void C()
            {
                var N = Read.Long();
                var K = Read.Long();
                var a = N % K;
                Console.WriteLine(Math.Min(a, K - a));
            }
            public static void D()
            {
                var K = Read.Int();
                var list = new List<long>();
                for(int keta = 1; keta <= 10; ++keta)
                {
                    for(int i = 1; i <= 9; ++i)
                    {
                        D_Loop(keta, i, 1, list);
                    }
                }
                Console.WriteLine(list[K - 1]);
            }
            static void D_Loop(int keta, long x, int current, List<long> list)
            {
                if (current == keta) { list.Add(x); return; }
                long last = x % 10;
                if(last > 0)
                {
                    D_Loop(keta, x * 10 + last - 1, current + 1, list);
                }
                D_Loop(keta, x * 10 + last, current + 1, list);
                if (last < 9)
                {
                    D_Loop(keta, x * 10 + last + 1, current + 1, list);
                }
            }
            public static void E()
            {
                var N = Read.Int();
                var K = Read.Int();
                var C = Read.Int();
                var S = Read.Str();
                var dp = new int[N + C + 2];
                for (int i = N; i > 0; --i)
                {
                    dp[i] = dp[i + 1];
                    if (S[i - 1] == 'o') { dp[i] = Math.Max(dp[i], dp[i + C + 1] + 1); }
                }
                if(dp[1] > K) { return; }
                int currentCount = 0;
                for(int i = 1; i <= N; ++i)
                {
                    if (S[i - 1] == 'o') { currentCount++; }
                    if (dp[i] > dp[i + 1])
                    {
                        if (currentCount == 1) { Console.WriteLine(i); i += C; }
                        currentCount = 0;
                    }
                }
                //Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
                //for(int i = 1; i <= N; ++i)
                //{
                //    if (S[i - 1] == 'o')
                //    {
                //        var v = dp[i];
                //        if (!dict.ContainsKey(v)) { dict.Add(v, new HashSet<int>()); }
                //        dict[v].Add(i);
                //    }
                //}
                //foreach(var h in dict.OrderBy(x => -x.Key))
                //{
                //    if (h.Value.Count == 1) { Console.WriteLine(h.Value.First());  }
                //}
            }
            public static void F()
            {
                var N = Read.Long();
                var divN1 = Util.Dividor(N - 1);
                var divN = Util.Dividor(N);
                long total = 0;
                foreach(var d in divN)
                {
                    var X = N;
                    while (X % d == 0) { X /= d; }
                    if (X % d == 1) {
                        total++;
                    }
                }
                Console.WriteLine(total + divN1.Count);
            }
            public static void F_X()
            {
                for(int i = 2; i <= 1000000; ++i)
                {
                    var a = F_My(i);
                    var b = F_Sim(i);
                    if (a != b || i%1000==0)
                    {
                        Console.WriteLine("{0}\t{1}\t{2}", i, F_My(i), F_Sim(i));
                    }
                }
            }
            static long F_My(long N)
            {
                var divN1 = Util.Dividor(N - 1);
                var divN = Util.Dividor(N);
                long total = 0;
                foreach (var d in divN)
                {
                    var X = N;
                    while (X % d == 0) { X /= d; }
                    if (X % d == 1)
                    {
                        total++;
                    }
                }
                return total + divN1.Count;
            }
            static long F_Sim(long N)
            {
                long count = 0;
                for(int i = 2; i <= N; ++i)
                {
                    var X = N;
                    while (X % i == 0) { X /= i; }
                    if (X % i == 1) { count++; }
                }
                return count;
            }
        }



        class Util
        {
            public static List<long> Dividor(long N)
            {
                var list = new List<long>();
                if (N > 1) { list.Add(N); }                
                for (long i = 2; i <= 1000000; ++i)
                {
                    if (i * i > N) { break; }
                    if (N % i == 0)
                    {
                        list.Add(i);
                        var j = N / i;
                        if (i != j) { list.Add(j); }
                    }
                }
                return list;
            }


            public static long Power(long a, long n, long p)
            {
                long res = 1;
                long mult = a;
                for (int i = 0; i < 40; ++i)
                {
                    if ((n & ((long)1 << i)) > 0)
                    {
                        res = (res * mult) % p;
                    }
                    mult = (mult * mult) % p;
                }
                return res;
            }
            public static long Inverse(long a, long p)
            {
                long b = p, c = 1, d = 0, e = 0, f = 0;
                while (b != 0)
                {
                    e = a / b;
                    f = b; b = a - e * b; a = f;
                    f = d; d = c - e * d; c = f;
                }
                c %= p;
                return c + (c < 0 ? p : 0);
            }
        }
        struct MOD
        {
            public static long P = 1000000007;
            public readonly long V;

            public MOD(long a) { this.V = a; }
            public static implicit operator MOD(long a) { return new MOD(a); }
            public static MOD operator +(MOD a, MOD b) { return new MOD((a.V + b.V) % P); }
            public static MOD operator -(MOD a, MOD b) { return new MOD((a.V - b.V + P) % P); }
            public static MOD operator *(MOD a, MOD b) { return new MOD((a.V * b.V) % P); }
            public static MOD operator /(MOD a, MOD b) { return new MOD((a.V * b.Inverse().V) % P); }
            public MOD Inverse() { return Util.Inverse(V, P); }
            public MOD Power(long n) { return Util.Power(V, n, P); }
            public override string ToString() { return V.ToString(); }
        }


        static class Read
        {
            static Queue<string> queue = new Queue<string>();
            static void Enqueue() { var ss = Console.ReadLine().Split(' '); foreach (var s in ss) { queue.Enqueue(s); } }
            public static int Int() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt32(queue.Dequeue()); }
            public static long Long() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt64(queue.Dequeue()); }
            public static string Str() { if (queue.Count == 0) { Enqueue(); } return queue.Dequeue(); }
            public static int[] IntN() { return Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray(); }
            public static long[] LongN() { return Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray(); }
            public static string[] StrN() { return Console.ReadLine().Split(' '); }
            public static Tuple<int, int>[] TupleInt(int n) { List<Tuple<int, int>> list = new List<Tuple<int, int>>(); for (int i = 0; i < n; ++i) { var ab = Read.IntN(); list.Add(new Tuple<int, int>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<long, long>[] TupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<string, string>[] TupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = Read.StrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<double, double>[] TupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); }
            public static long[,] LongMatrix(int r, int c)
            {
                var mat = new long[r, c];
                for (int i = 0; i < r; ++i)
                {
                    var x = Read.LongN();
                    for (int j = 0; j < c; ++j)
                    {
                        mat[i, j] = x[j];
                    }
                }
                return mat;
            }
            public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M)
            {
                Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
                for (int i = 0; i <= N; ++i)
                {
                    dict.Add(i, new HashSet<int>());
                }
                for (int i = 0; i < M; ++i)
                {
                    var ab = Read.IntN();
                    dict[ab[0]].Add(ab[1]);
                    dict[ab[1]].Add(ab[0]);
                }
                return dict;
            }
            public static Dictionary<int, Dictionary<int, long>> AdjacencyListWithWeight(int N, int M)
            {
                Dictionary<int, Dictionary<int, long>> dict = new Dictionary<int, Dictionary<int, long>>();
                for (int i = 0; i <= N; ++i)
                {
                    dict.Add(i, new Dictionary<int, long>());
                }
                for (int i = 0; i < M; ++i)
                {
                    var ab = Read.IntN();
                    dict[ab[0]].Add(ab[1], ab[2]);
                    dict[ab[1]].Add(ab[0], ab[2]);
                }
                return dict;
            }
        }
    }
}


Measured memory_bytes: 13396