#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> v;
  long long a, z;
  cin >> a;
  z = a;
  for (int i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) {
      z = i;
      break;
    }
  }
  if (a == z)
    cout << 1;
  else if (z == 2)
    cout << a / 2;
  else
    cout << (a - z) / 2 + 1;
}
