#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007, mxn = 1000010;
int main() {
  long long n;
  cin >> n;
  long long d = 2;
  while (d * d <= n) {
    if (n % d == 0) {
      break;
    }
    d++;
  }
  if (n % d != 0)
    cout << "1" << endl;
  else {
    cout << 1 + (n - d) / 2 << endl;
  }
}
