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