#include <bits/stdc++.h>
const int MAX = 1e6;
using namespace std;
const int alpha = 26;
long long int smallest(long long int n) {
  for (long long int i = 2; i * i <= n; i++)
    if (n % i == 0) return i;
  return n;
}
void solve() {
  long long int n;
  cin >> n;
  long long int count = 0;
  if (n % 2 != 0) {
    n -= smallest(n);
    count++;
  }
  cout << count + n / 2;
}
int main() {
  solve();
  return 0;
}
