#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 55;
char s[MAXN];
int main() {
  long long n;
  scanf("%lld", &n);
  long long ans = 0;
  long long tmp = -1;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      tmp = i;
      break;
    }
  }
  if (tmp == -1) tmp = n;
  if (tmp == 2) {
    printf("%lld\n", n / 2);
  } else {
    ans = 1;
    printf("%lld\n", ans + (n - tmp) / 2);
  }
  return 0;
}
