You are given an integer number n. The following algorithm is applied to it:

  1. if n = 0, then end algorithm; 
  2. find the smallest prime divisor d of n; 
  3. subtract d from n and go to step 1. 



Determine the number of subtrations the algorithm will make.

Input

The only line contains a single integer n (2 ≤ n ≤ 10^{10}).

Output

Print a single integer — the number of subtractions the algorithm will make.

Examples

Input


5


Output


1


Input


4


Output


2

Note

In the first example 5 is the smallest prime divisor, thus it gets subtracted right away to make a 0.

In the second example 2 is the smallest prime divisor at both steps.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Created by timur on 28.03.15.
 */

public class TaskB {
    boolean eof;
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new TaskB().run();
    }

    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return "-1";
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() {
        return Long.parseLong(nextToken());
    }

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

    String nextLine() throws IOException {
        return br.readLine();
    }


    void run() throws IOException {
        InputStream input = System.in;
        PrintStream output = System.out;
        try {
            File f = new File("a.in");
            if (f.exists() && f.canRead()) {
                input = new FileInputStream(f);
                output = new PrintStream("a.out");
            }
        } catch (Throwable e) {
        }
        br = new BufferedReader(new InputStreamReader(input));
        out = new PrintWriter(output);
        solve();
        br.close();
        out.close();
    }

    long gcd(long a, long b) {
        if (b == 0)
            return a;
        else
            return gcd(b, a % b);
    }


    void solve() {
        int MAXP = 100003;
        boolean[] np = new boolean[MAXP];
        long[] primes;

        for (int i = 2; i * i < MAXP; i++) {
            if (!np[i]) {
                for (int j = i * i; j < MAXP; j += i) {
                    np[j] = true;
                }
            }
        }
        int count = 0;
        for (int i = 2; i < MAXP; i++) {
            if (!np[i]) {
                count++;
            }
        }
        primes = new long[count];
        for (int i = 2, j = 0; i < MAXP; i++) {
            if (!np[i]) {
                primes[j++] = i;
            }
        }
        
        
        long n = nextLong();
        int ans = 0;
        boolean upd = true;
        while (upd && n > 0) {
            upd = false;
            if (n % primes[0] == 0) {
                ans += n / 2;
                n = 0;
                break;
            }
            for (int i = 1; i < count; i++) {
                if (n % primes[i] == 0) {
                    n -= primes[i];
                    upd = true;
                    ans++;
                    break;
                }
            }
        }
        if (n > 0) {
            ans++;
        }
        out.print(ans);
    }
}
