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;
const int INF = 2000000009;
const int MX = 100005;
const double EPS = 1e-9;
const int MOD = 1000000007;
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
map<long long, long long> pf;
map<long long, long long>::iterator it;
long long precal(long long n) {
  while ((n % 2) == 0) {
    pf[2]++;
    n /= 2;
  }
  for (long long i = 3; i <= sqrtl(n); i++) {
    while (n % i == 0) {
      pf[i]++;
      n /= i;
    }
  }
  if (n > 1) pf[n]++;
}
int main() {
  long long n = ({
    int a;
    read(a);
    a;
  });
  if (n % 2 == 0)
    cout << n / 2 << '\n';
  else {
    precal(n);
    it = pf.begin();
    n -= it->first;
    cout << (n / 2) + 1 << '\n';
  }
  return 0;
}
