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