#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, ans, sum, k;
bool ok;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  while (n) {
    ok = true;
    if (n % 2 == 0) {
      ans += n / 2;
      cout << ans << endl;
      return 0;
    }
    for (i = 3; i * i <= n; i++) {
      if (n % i == 0) {
        ans++;
        n -= i;
        ok = false;
        break;
      }
    }
    if (ok) {
      n = 0;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
