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 long double EPS = 1e-10;
const int MOD = 1000000007ll;
const int mod1 = 1000000009ll;
const int mod2 = 1100000009ll;
int INF = (int)1e9;
long long int INFINF = (long long int)1e18;
long double PI = acos(-1.0);
int bit_count(long long int _x) {
  long long int _ret = 0;
  while (_x) {
    if (_x % 2 == 1) _ret++;
    _x /= 2;
  }
  return _ret;
}
int bit(long long int _mask, int _i) {
  return (_mask & (1ll << _i)) == 0 ? 0 : 1;
}
int add(int a, int b, int m = MOD) {
  int x = a + b;
  while (x >= m) x -= m;
  while (x < 0) x += m;
  return x;
}
int sub(int a, int b, int m = MOD) {
  int x = a - b;
  while (x < 0) x += m;
  while (x >= m) x -= m;
  return x;
}
int mul(int a, int b, int m = MOD) {
  long long int x = a * 1ll * b;
  x %= m;
  while (x < 0) x += m;
  return (int)x;
}
int ldtoint(long double x) { return (int)(x + 0.5); }
long long int ldtolli(long double x) { return (long long int)(x + 0.5); }
int powermod(long long int _a, long long int _b, int _m = MOD) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = mul(_r, _a, _m);
    _b >>= 1;
    _a = mul(_a, _a, _m);
  }
  return _r;
}
template <class T>
T Max2(T a, T b) {
  return a < b ? b : a;
}
template <class T>
T Min2(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T Max3(T a, T b, T c) {
  return Max2(Max2(a, b), c);
}
template <class T>
T Min3(T a, T b, T c) {
  return Min2(Min2(a, b), c);
}
template <class T>
T Max4(T a, T b, T c, T d) {
  return Max2(Max2(a, b), Max2(c, d));
}
template <class T>
T Min4(T a, T b, T c, T d) {
  return Min2(Min2(a, b), Max2(c, d));
}
template <class T>
void Swap(T& a, T& b) {
  T temp;
  temp = a;
  a = b;
  b = temp;
}
template <class T>
T Abs(T a) {
  if (a < 0) a = -a;
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long nn = sqrt(n) + 1000000;
  bool seive[nn + 1];
  memset(seive, true, sizeof seive);
  seive[0] = seive[1] = false;
  for (int i = 2; i * i <= nn; i++)
    if (seive[i])
      for (int j = i * i; j <= nn; j += i) seive[j] = false;
  for (int i = 2; i <= sqrt(n) + 1; i++) {
    if (seive[i]) {
      if (n % i == 0) {
        if (i % 2) {
          cout << (1 + (n - i) / 2);
          return 0;
        } else {
          cout << n / i;
          return 0;
        }
      }
    }
  }
  cout << 1 << '\n';
  return 0;
}
