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