#include <bits/stdc++.h>
using namespace std;
long long int isSmallestPrime(long long int n) {
  for (long long int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      return i;
    }
  }
  return n;
}
int main() {
  long long int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n / 2;
    return 0;
  } else {
    long long int d = isSmallestPrime(n);
    long long int x = n - d;
    cout << 1 + x / 2 << endl;
    return 0;
  }
}
