#include <bits/stdc++.h>
using namespace std;
int i, j, k;
int main() {
  unsigned long long n;
  scanf("%lld", &n);
  unsigned long long cnt = 0;
  if (n % 2 == 0)
    cnt = n / 2;
  else {
    unsigned long long lmt = sqrt(1 + n);
    for (i = 3; i <= lmt; i++) {
      if (n % i == 0) {
        n -= i;
        cnt = n / 2 + 1;
        break;
      }
    }
    if (cnt == 0) cnt = 1;
  }
  printf("%lld\n", cnt);
}
