#include <bits/stdc++.h>
using namespace std;
long long check(long long val) {
  for (long long i = 2; i * i <= val; i++) {
    if (val % i == 0) return 0;
  }
  return 1;
}
int main() {
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    if (check(n)) {
      cout << 1 << endl;
      continue;
    }
    long long ans = 0;
    for (long long i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        ans++;
        n -= i;
        break;
      }
    }
    ans += n / 2;
    cout << ans << endl;
  }
}
