#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int s = 0, n, i, l = 0, k;
  cin >> n;
  while (1) {
    s = 0;
    if (n <= 0) break;
    for (i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        l += 1;
        n = n - i;
        s = 1;
        break;
      }
    }
    if (s == 0) {
      l = 1;
      break;
    }
    if (n % 2 == 0) {
      l = l + (n / 2);
      break;
    }
  }
  cout << l;
}
