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