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