#include <bits/stdc++.h>
const int Inf = 2e9;
long long LINF = (long long)4e18;
using namespace std;
long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      if (n - i > 0 && (n - i) % 2 == 0)
        cout << (n - i) / 2 + 1;
      else
        cout << n / i;
      return 0;
    }
  }
  cout << 1;
  return 0;
}
