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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Itwazonce
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scan in = new Scan(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDivisorSubtraction solver = new BDivisorSubtraction();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDivisorSubtraction {
        public void solve(int testNumber, Scan in, PrintWriter out) {
            long n = in.scanLong();
            long max = n;
            if (max % 2 == 0) {
                out.println(max / 2);
                return;
            }
            if (isprime(max)) {
                out.println(1);
                return;
            }
            long ans = 0;
            for (long i = 2; i <= n; i++) {
                if (max % i == 0 && isprime(i)) {
                    max -= i;
                    ans++;
                    if (max % 2 == 0) {
                        out.println(ans + max / 2);
                        return;
                    }
                    if (isprime(max)) {
                        out.println(ans + 1);
                        return;
                    }
                }
            }
            if (max % 2 == 0) {
                out.println(max / 2);
                return;
            }
        }

        static boolean isprime(long h) {
            for (long g = 2; g <= Math.sqrt(h); g++) {
                if (h % g == 0) {
                    return false;
                }
            }
            return true;
        }

    }

    static class Scan {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public Scan(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public long scanLong() {
            long I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

    }
}

