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