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 modulo(long long base, long long exponent, long long modulus);
long long powermodm(long long x, long long n, long long M) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long power(long long _a, long long _b) {
  long long _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
long long isPrime[100001];
void sieve() {
  for (long long i = 0; i <= 100001; ++i) {
    isPrime[i] = 1;
  }
  isPrime[0] = 0;
  isPrime[1] = 0;
  for (long long i = 2; i * i <= 100001; ++i) {
    if (isPrime[i] == 1) {
      for (long long j = i * i; j <= 100001; j += i) isPrime[j] = 0;
    }
  }
}
vector<unsigned long long> Divisors(unsigned long long n) {
  vector<unsigned long long> a;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        a.push_back(i);
      else {
        a.push_back(i);
        a.push_back(n / i);
      }
    }
  }
  return a;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  unsigned long long n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n / 2;
    return 0;
  }
  sieve();
  unsigned long long ans = 0;
  vector<unsigned long long> a = Divisors(n);
  if (a.size() == 2) {
    cout << 1;
    return 0;
  }
  sort(a.begin(), a.end());
  for (long long i = 0; i < a.size(); i++) {
    if (isPrime[a[i]] == 1 && a[i] != 1) {
      n = n - a[i];
      break;
    }
  }
  ans++;
  ans = ans + (n / 2);
  cout << ans;
}
