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 mult(long long a, long long b, long long p = 1000000007) {
  long long ans = ((a % p) * (b % p)) % p;
  return (ans + p) % p;
}
long long add(long long a, long long b, long long p = 1000000007) {
  long long ans = (a % p + b % p) % p;
  return (ans + p) % p;
}
long long fpow(long long n, long long k, long long p = 1000000007) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
long long inv(long long a, long long p = 1000000007) {
  return fpow(a, p - 2, p);
}
vector<bool> prime(100005, 0);
vector<long long> vec;
void sieve() {
  for (int i = 2; i < 100005; i++) {
    if (!prime[i]) {
      vec.push_back((long long)(i));
      for (int j = 2 * i; j < prime.size(); j += i) prime[j] = 1;
    }
  }
}
int main() {
  sieve();
  long long n;
  cin >> n;
  long long ans = 0;
  if (n % 2) {
    int i;
    for (i = 0; i < ((int)(vec).size()); ++i)
      if (n % vec[i] == 0) break;
    ans += 1;
    if (i == ((int)(vec).size()))
      n = 0;
    else
      n -= vec[i];
  }
  if (n) ans += (n / 2ll);
  cout << ans << endl;
  return 0;
}
