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;
template <class T>
inline bool read(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return false;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return true;
}
inline long long qmul(long long, long long, long long);
inline long long qpow_qmul(long long, long long, long long);
inline long long qpow(long long, long long, long long);
inline long long gcd(long long, long long);
const int N = 1e6 + 10;
const long long INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double PI = acos(-1.0);
long long prime[N];
int tot, vis[N];
void pre(long long n) {
  memset(vis, 0, sizeof(vis));
  for (long long i = 2; i <= n; i++) {
    if (!vis[i]) prime[tot++] = 1ll * i;
    for (long long j = 0; j < tot && i * prime[j] <= n; j++) {
      vis[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  long long n;
  scanf("%I64d", &n);
  if (n % 2 == 0) {
    printf("%I64d\n", n / 2);
  } else {
    long long ans = 0;
    pre(sqrt(n) + 1000);
    for (int i = 0; i < tot; i++) {
      if (n % prime[i] == 0) {
        ans = 1 + (n - prime[i]) / 2;
        break;
      }
    }
    if (ans == 0) ans++;
    printf("%I64d\n", ans);
  }
  return 0;
}
inline long long qmul(long long a, long long b, long long mod) {
  long long ans = 0, x = a;
  while (b) {
    if (b & 1) {
      ans += x % mod;
      ans %= mod;
    }
    x *= 2;
    x %= mod;
    b >>= 1;
  }
  return ans % mod;
}
inline long long qpow_qmul(long long x, long long n, long long mod) {
  long long ans = 1, a = x % mod;
  while (n) {
    if (n & 1) {
      ans = qmul(ans, a, mod);
      ans %= mod;
    }
    a = qmul(a, a, mod);
    a %= mod;
    n >>= 1;
  }
  return ans;
}
inline long long qpow(long long x, long long n, long long mod) {
  long long ans = 1, a = x % mod;
  while (n) {
    if (n & 1) {
      ans *= a % mod;
      ans %= mod;
    }
    a *= a % mod;
    a %= mod;
    n >>= 1;
  }
  return ans;
}
inline long long gcd(long long m, long long n) {
  return n == 0 ? m : gcd(n, m % n);
}
