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