#include <bits/stdc++.h>
using namespace std;
const int N = 1005505;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long cnt = 0;
  while (n % 2 != 0) {
    long long wn = n;
    for (long long i = 2; i * i <= n; ++i)
      if (n % i == 0) {
        n -= i;
        ++cnt;
        break;
      }
    if (wn == n) {
      ++cnt;
      cout << cnt;
      return 0;
    }
  }
  cnt += n / 2;
  cout << cnt;
  return 0;
}
