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.util.*;

public class cf_edu54_div2 {
	public static Scanner scn = new Scanner(System.in);
	public static double checker = Math.pow(10, -6);

	public static void main(String[] args) {
//		int t = scn.nextInt();
//		for (int i = 0; i < t; i++)
//			Q3();
		Q2();

	}

	private static void Q1() {
		int n = scn.nextInt();
		String s = scn.next();
		for (int i = 0; i < s.length() - 1; i++) {
			if (s.charAt(i) > s.charAt(i + 1)) {
				String res = "";
				if (i == 0) {
					res = s.substring(1);
				} else {
					res = s.substring(0, i) + s.substring(i + 1);
				}
				System.out.println(res);
				return;
			}
		}
		System.out.println(s.substring(0, n - 1));
	}

	public static void Q3() {
		double d = scn.nextDouble();
		double x1 = 0;
		double x2 = 0;
		double y1 = 0;
		double y2 = 0;
		y1 = (d + Math.sqrt(d * d - 4 * d)) / 2;
		x1 = d - y1;
		y2 = (d - Math.sqrt(d * d - 4 * d)) / 2;
		x2 = d - y2;
		if (y1 >= 0 && x1 >= 0) {
			if (Math.abs(y1 + x1 - y1 * x1) <= checker && Math.abs(y1 + x1 - d) <= checker) {
				System.out.println("Y " + Math.max(y1, x1) + " " + Math.min(y1, x1));
				return;
			}
		}
		if (y2 >= 0 && x2 >= 0) {
			if (Math.abs(y2 + x2 - y2 * x2) <= checker && Math.abs(y2 + x2 - d) <= checker) {
				System.out.println("Y " + Math.max(y2, x2) + " " + Math.min(y2, x2));
				return;
			}

		}
		System.out.println("N");
	}

	public static void Q2() {
		long num = scn.nextLong();
		int n = 100009;
		int[] lp = new int[n + 1];

		// We need to print 1 for 1.
		lp[1] = 1;

		for (int i = 2; i <= n; i++) {
			
			if (lp[i] == 0) {
				
				lp[i] = i;

				for (int j = 2 * i; j <= n; j += i)
					if (lp[j] == 0)
						lp[j] = i;
			}
		}
		long ans = 0;
		if(num>=lp.length) {
			for (int i = 2; i < lp.length; i++) {
				if(lp[i]==i && num%lp[i]==0) {
					if(num%2==0) {
						ans+=num/2;
					}else {
						ans= num/2+1;
					}
					System.out.println(ans);
					return;
				}
				System.out.println(1);
				return;
			}
		}else {
			if(num%2==0) {
				ans+=num/2;
			}else {
				ans= num/2+1;
			}
		}
		System.out.println(ans);
		return;
			
	}
}
