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