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