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.
#include <bits/stdc++.h>
int main() {
  long long int ar[100002] = {0}, i, j;
  for (i = 2; i < 100002; i = i + 2) ar[i] = 1;
  for (i = 3; i <= sqrt(100002); i = i + 2) {
    if (ar[i] == 0) {
      for (j = i * i; j < 100002; j = j + 2 * i) {
        ar[j] = 1;
      }
    }
  }
  long long int n;
  while (scanf("%lld", &n) != EOF) {
    int x = 1, p = 1;
    if (n % 2 == 0) {
      printf("%lld\n", n / 2);
      p = 0;
    } else if (n < 100000) {
      if (ar[n] == 0) {
        printf("1\n");
      } else {
        x = 0;
      }
    }
    if ((x == 0 || n >= 100000) && p == 1) {
      int f = 1;
      for (i = 3; i <= sqrt(n); i = i + 2) {
        if (ar[i] == 0 && n % i == 0) {
          n = n - i;
          printf("%lld\n", n / 2 + 1);
          f = 0;
          break;
        }
      }
      if (f) printf("1\n");
    }
  }
  return 0;
}
