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