#include <bits/stdc++.h>
using namespace std;
long long get(long long n) {
  for (long long i = 2; i * i <= n; ++i)
    if (n % i == 0) return i;
  return n;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  int c = 0;
  while (n % 2 != 0) {
    n -= get(n);
    c++;
  }
  cout << c + n / 2 << endl;
}
