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