#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ans = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ans = i;
      break;
    }
  }
  int count = 0;
  if (n % 2 != 0) {
    n -= ans;
    count++;
  }
  cout << count + n / 2;
}
