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 <typename T>
T read() {
  T p = 1, x = 0;
  char s = getchar();
  while (s == ' ' || s == '\n') s = getchar();
  if (s == '-') p = -1, s = getchar();
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * p;
}
template <typename A, typename B>
void Umax(A &a, const B &b) {
  if (a < b) a = b;
}
template <typename A, typename B>
void Umin(A &a, const B &b) {
  if (a > b) {
    a = b;
  }
}
long long bin_pow(long long a, long long n) {
  if (n == 0) {
    return 1;
  }
  if (n % 2 == 1) {
    long long cnt = a * bin_pow(a, n - 1);
    return cnt;
  } else {
    long long cnt = bin_pow(a, n / 2);
    return cnt * cnt;
  }
}
const int N = (int)1e6 + 10;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
void brute(int a) {
  int cnt = 0;
  int z = a;
  while (true) {
    if (a == 0) {
      cout << z << ' ' << cnt << ' ';
      return;
    }
    for (int i = 2; i <= a; ++i) {
      if (a % i == 0) {
        a -= i;
        cnt++;
        break;
      }
    }
  }
}
bool check(long long a) {
  for (int i = 2; i <= sqrt(a) + 2; ++i) {
    if (a % i == 0) return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long i;
  cin >> i;
  if (check(i)) {
    cout << 1 << endl;
  } else if (i % 2 == 0) {
    cout << i / 2 << endl;
  } else {
    long long z = i;
    for (int j = 2; j <= i; ++j) {
      if (z % j == 0) {
        z -= j;
        cout << z / 2 + 1 << endl;
        break;
      }
    }
  }
  return 0;
}
