#include <bits/stdc++.h>
using namespace std;
long long n;
void solve() {
  cin >> n;
  if (n % 2 == 0) {
    cout << n / 2;
  } else {
    bool flag = 0;
    for (long long i = 3; i * i <= n; i += 2)
      if (n % i == 0) {
        n -= i;
        flag = 1;
        break;
      }
    if (!flag)
      cout << 1;
    else
      cout << n / 2 + 1;
  }
}
int main() {
  solve();
  fclose(stdin);
  fclose(stdout);
  return 0;
}
