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