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