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.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] argv) throws Exception {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		long n = in.nextLong();
		if (n % 2 == 0) {
			out.println(n / 2);
		} else {
			long ct = 0;
			boolean flag = false;
			while (n > 0) {
				long x = nextPrime(n);
				n -= x;
				++ct;
				if (n % 2 == 0) {
					out.println((n / 2) + ct);
					flag = true;
					break;
				}
			}
			if (!flag) {
				out.println(ct);
			}
		}
		out.flush();
		out.close();

	}

	private static long nextPrime(long n) {
		// TODO Auto-generated method stub
		TreeSet<Long> set = new TreeSet<>();
		for (long i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0) {
				if (isPrime(i)) {
					return i;
				} else {
					set.add(n / i);
				}
			}
		}
		set.add(n);
		for (int i = 0; i < set.size(); i++) {
			long x = set.pollFirst();
			if (isPrime(x)) {
				return x;
			}
		}
		return 0;
	}

	private static boolean isPrime(long b) {
		// TODO Auto-generated method stub
		for (int i = 2; i <= Math.sqrt(b); i++) {
			if (b % i == 0) {
				return false;
			}
		}
		return true;
	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}