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>
using namespace std;
long long int N = 1e5 + 10;
long long int prime[10000];
bool mark[100050];
long long int primelen;
void sieve() {
  long long int limit = sqrt(N * 1.0) + 2;
  for (long long int i = 4; i <= N; i += 2) mark[i] = 1;
  prime[primelen++] = 2;
  for (long long int i = 3; i <= N; i += 2) {
    if (!mark[i]) {
      prime[primelen++] = i;
      if (i <= limit) {
        for (long long int j = i * i; j <= N; j += i) mark[j] = 1;
      }
    }
  }
}
long long int multimod(long long int a, long long int b, long long int m) {
  long long int x = 0, y = a % m;
  while (b) {
    if (b % 2) x = (x + y) % m;
    y = (y + y) % m;
    b /= 2;
  }
  return x % m;
}
long long int modulo(long long int a, long long int b, long long int m) {
  long long int x = 1, y = a;
  while (b) {
    if (b % 2) x = (x * y) % m;
    y = (y * y) % m;
    b /= 2;
  }
  return x % m;
}
bool isprime(long long int n) {
  long long int s;
  int test = 5;
  if (n != 2 && !(n % 2)) return false;
  s = n - 1;
  while (!(s % 2)) s /= 2;
  for (int i = 0; i < test; i++) {
    long long int a = rand() % (n - 1) + 1;
    long long int tmp = s;
    long long int mod = modulo(a, tmp, n);
    while (tmp != n - 1 && mod != 1 && mod != n - 1) {
      mod = multimod(mod, mod, n);
      tmp *= 2;
    }
    if (mod != n - 1 && !(tmp % 2)) return false;
  }
  return true;
}
int main() {
  sieve();
  long long int n;
  int res = 0;
  cin >> n;
  if (!(n % 2)) return cout << n / 2 << endl, 0;
  while (n) {
    if (isprime(n)) {
      res++;
      break;
    }
    if (!(n % 2)) {
      res += n / 2;
      break;
    }
    for (long long int i = 0; i < primelen; i++) {
      if (!(n % prime[i])) {
        res++;
        n -= prime[i];
        break;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
