#include <bits/stdc++.h>
using namespace std;
void past_code();
int main() {
  bool b = true;
  long long x, y;
  cin >> x;
  if (x % 2 == 0)
    cout << x / 2 << endl;
  else {
    y = sqrt((long double)x);
    for (int i = 3; i <= y; i++) {
      if (x % i == 0) {
        b = false;
        x = x - i;
        break;
      }
    }
    if (!b)
      cout << x / 2 + 1 << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}
