#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  if (n % 2 == 0)
    ans = n / 2;
  else {
    for (long long i = 3; i * i <= n; i += 2) {
      if (n % i == 0) {
        ans += 1;
        n -= i;
        break;
      }
    }
    if (ans > 0)
      ans += (n / 2);
    else
      ans = 1;
  }
  cout << ans << "\n";
}
