#include <bits/stdc++.h>
const int N = 5e5 + 10, M = 1e7 + 10;
const long long mod = 1e9 + 7;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      cout << 1 + (n - i) / 2 << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}
