#include <bits/stdc++.h>
using namespace std;
int is_prime(long long n) {
  int flag = 1;
  for (long long i = 2; i < sqrt(n) + 1; i++) {
    if (n % i == 0) {
      flag = 0;
      break;
    }
  }
  return flag;
}
int main() {
  long long n, count = 0;
  cin >> n;
  while (n % 2) {
    count++;
    if (is_prime(n)) {
      n = 0;
      break;
    }
    long long d;
    for (long long i = 2; i < sqrt(n + 1); i++) {
      if (is_prime(i) && n % i == 0) {
        d = i;
        break;
      }
    }
    n -= d;
  }
  count += n / 2;
  cout << count << endl;
  return 0;
}
