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 math

n = int(input())
countOfSubtractions = 0
iteraction = 0
even = [0,2,4,6,8]

while n > 0:
  subtract = 0
  
  iteraction += 1
  lastChar = int(str(n)[-1])
  #print("Starting iteraction #" + str(iteraction) + " with n = " + str(n) + " with lastChar = " + str(lastChar))
  
  if (lastChar in even):
    countOfSubtractions += int(n/2) - 1
    n = -1
  
  elif (lastChar == '3'):                     subtract = 3
  elif (sum([int(x) for x in str(n)]) == 3):  subtract = 3
  elif (lastChar == '5'):                     subtract = 5
  elif (n % 7 == 0):                          subtract = 7

  else:
    i = 3
    while(math.pow(i,2) <= n): 
      if (n % i == 0): 
        subtract = i
        break
      i += 2
    if(subtract == 0): subtract = n
  
  #print("Finishing interaction #" + str(iteraction) + ". n is now = " + str(n) + ", subtract is now = " + str(subtract))
  n -= subtract
  countOfSubtractions+=1

print(countOfSubtractions)