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