#include <bits/stdc++.h>
using namespace std;
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, -1, 1};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long cnt = 0;
  while (true) {
    if (!(n & 1)) {
      cout << cnt + n / 2;
      return 0;
    }
    bool stop = false;
    for (long long i = 3; i * i <= n; i += 2) {
      if (n % i == 0) {
        n -= i;
        stop = 1;
        cnt++;
        break;
      }
    }
    if (!stop) {
      cout << 1 << "\n";
      return 0;
    }
  }
}
