#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  int var = 0;
  if (n % 2 == 0) {
    cout << n / 2;
    return 0;
  }
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      var = i;
      break;
    }
  }
  if (var == 0)
    n = 0;
  else
    n -= var;
  cout << 1 + (n / 2) << "\n";
}
