284_A. Cows and Primitive Roots_8800
The cows have just learned what a primitive root is! Given a prime p, a primitive root <image> is an integer x (1 ≤ x < p) such that none of integers x - 1, x2 - 1, ..., xp - 2 - 1 are divisible by p, but xp - 1 - 1 is. 

Unfortunately, computing primitive roots can be time consuming, so the cows need your help. Given a prime p, help the cows find the number of primitive roots <image>.

Input

The input contains a single line containing an integer p (2 ≤ p < 2000). It is guaranteed that p is a prime.

Output

Output on a single line the number of primitive roots <image>.

Examples

Input

3


Output

1


Input

5


Output

2

Note

The only primitive root <image> is 2.

The primitive roots <image> are 2 and 3.

import java.io.*;
import java.util.*;

public class pp1 {
    FastScanner in;
    PrintWriter out;
    class Graph{
        int V;
        ArrayList<Integer> adjlist[];
        Graph(int n){
            this.V = n;
            this.adjlist = new ArrayList[n];
            for(int i=0;i<this.V;i++){
                adjlist[i] = new ArrayList<>();
            }
        }
        void addEdge(int u, int v){
            adjlist[u].add(v);
            adjlist[v].add(u);
        }
        int dfs(int start, int dest, boolean[] vis, List<Integer> happy){
            vis[start]=true;
            int sum=0;
            boolean flag=false;
            for(int i=0;i<adjlist[start].size();i++){
                int b = adjlist[start].get(i);
                if(!vis[b]){
                    flag=true;
                    sum+=dfs(b, dest+1,vis, happy );
                }
            }
            int remain = dest-sum;
            happy.add(remain);
            return sum+1;
        }



    }

    boolean isPrimitive(int x, int p) {
        int last = getPow(x, p-1, p) - 1;
        if (last % p != 0) return false;

        for (int pow = 1; pow < p-1; pow++) {
            int curr = getPow(x, pow, p) - 1;

            if (curr % p == 0) return false;
        }

        return true;
    }

    int getPow(int x, int power, int mod) {
        if (power == 1) {
            return x;
        }

        long half = getPow(x, power / 2, mod) % mod;

        if (power % 2 == 0) {
            return (int)(half * half) % mod;
        }
        else {
            return (int)((half * half % mod) * x) % mod;
        }
    }
    void solve() {
        //This is the main logic code
        int p = in.nextInt();
        int count = 0;

        for (int x = 1; x < p; x++) {
            if (isPrimitive(x, p)) {
                count++;
            }
        }

        out.println(count);




    }

    public static void main(String[] args) {
        new pp1().runIO();
    }

    void run() {
        try {
            in = new FastScanner(new File("A.in"));
            out = new PrintWriter(new File("A.out"));
            solve();
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}