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