#include <bits/stdc++.h>
using namespace std;
bool prime(long long n) {
  if (n < 2) return 0;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  std::ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  long long n;
  cin >> n;
  if (!(n & 1)) return cout << n / 2 << endl, 0;
  if (prime(n)) return cout << 1 << endl, 0;
  if (n % 2) {
    for (long long i = 2; i * i <= n; i++)
      if (n % i == 0 && prime(i)) {
        n -= i;
        break;
      }
    cout << n / 2 + 1 << endl;
  }
}
