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;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%lld", &aaa);
  return aaa;
}
inline double dxt() {
  double aaa;
  scanf("%lf", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
vector<int> primes;
bool mark[1000010];
void sieve(int n) {
  primes.push_back(2);
  for (int i = 3; i * i <= n; i += 2)
    if (mark[i] == 0)
      for (int j = i * i; j <= n; j += i * 2) mark[j] = 1;
  for (int i = 3; i <= n; i += 2)
    if (!mark[i]) primes.push_back(i);
}
int main() {
  sieve(1000010 - 1);
  long long int n = lxt();
  if (n % 2 == 0) {
    cout << n / 2 << endl;
    return 0;
  }
  for (int i = 0; (long long int)primes[i] * (long long int)primes[i] <= n;
       i++) {
    if (n % primes[i] == 0) {
      cout << (n - primes[i]) / 2 + 1 << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}
