#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int main() {
  long long n;
  cin >> n;
  if (n % 2 == 0) {
    cout << 1ll * n / 2;
    return 0;
  }
  bool flag = true;
  for (int i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      cout << 1ll * (n - i) / 2 + 1;
      return 0;
    }
  }
  cout << "1";
  return 0;
}
