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.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner input = new Scanner(System.in)){
			boolean primes[] = new boolean[100001];
			for(int i =0; i < 100001;i++) {
				primes[i] = true;
			}
			primes[0] = false;
			primes[1] = false;
			long n = Long.parseLong(input.nextLine()); // n vai ate 10^12 (long)
			sieveOfEratosthenes(squareRoot(n), primes); //squareRoot(n) vai ate 10^6 (int)
			algorithm(n, 0, primes);
		}
	}
	private static void sieveOfEratosthenes(int x, boolean[] primes){ 
        for(int p = 2; p*p <=x; p++){
            if(primes[p] == true) { 
                for(int i = p*p; i < x; i += p) {
                    primes[i] = false; 
                }
            } 
        } 
    }
	private static int squareRoot(long n) {
		int root = (int) Math.pow(n, 0.5) - 1;
		if(root*root == n) {return root;}
		root++;
		if(root*root>n) { //essa  verificacao eh para raizes quadradas nao exatas, como a de 5. Se essa verificacao, a raiz de 5 seria -1 e nao 2
			return root-1;
		}
		if(root*root == n) {return root;}
		root++;
		if(root*root>n) {
			return root-1;
		}
		if(root*root == n) {return root;}

		return -1;
	}
	private static void algorithm(long n, long subtractions, boolean[] primes){
//		System.out.println("n: " + n);
//		System.out.println("sub: " + subtractions);

		if(n<=0) {
			System.out.println(subtractions);
			return;
		}
		if(n%2==0) { //se for divisivel por 2, entao vao ocorrer n/2 recursoes e consequentemente n/2 subtracoes
			subtractions += n/2; 
			algorithm(0, subtractions, primes); // pra poupar tempo e encerrar o algoritmo logo
		}else {
			long d = findD(n, primes);
			subtractions++;
		
			algorithm(n-d, subtractions, primes);
		}
	}
	
	private static long findD(long n, boolean[] primes) {
		for(long d = 2; d < primes.length;d++) {
//			System.out.println("i: " + i);
//			System.out.println("primes[i]: " + primes[(int) i]);
			if(primes[(int)d] && n%d==0){ //procura o menor primo que divide n
				return d;
			}
		}
		return n;
	}
}