#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n / 2 << "\n";
    return 0;
  }
  long long ans = n;
  for (long long int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      ans = i;
      break;
    }
  }
  cout << (n - ans) / 2 + 1 << "\n";
  return 0;
}
