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