#include <bits/stdc++.h>
int main(void) {
  long long int n, i;
  scanf("%lld", &n);
  long long int count = 0;
  if (!(n & 1))
    count = n / 2;
  else {
    for (i = 3; i * i <= n; i += 2) {
      if (!(n % i)) {
        count++;
        n -= i;
        break;
      }
    }
    if (n & 1) {
      n = 0;
      count++;
    }
    count += n / 2;
  }
  printf("%lld\n", count);
  return 0;
}
