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