You are given an integer number n. The following algorithm is applied to it:

  1. if n = 0, then end algorithm; 
  2. find the smallest prime divisor d of n; 
  3. subtract d from n and go to step 1. 



Determine the number of subtrations the algorithm will make.

Input

The only line contains a single integer n (2 ≤ n ≤ 10^{10}).

Output

Print a single integer — the number of subtractions the algorithm will make.

Examples

Input


5


Output


1


Input


4


Output


2

Note

In the first example 5 is the smallest prime divisor, thus it gets subtracted right away to make a 0.

In the second example 2 is the smallest prime divisor at both steps.
#include <bits/stdc++.h>
using namespace std;
const long long int M = 1000000007;
const long long int M1 = 998244353;
const double PI = 3.141592653589793;
vector<long long int> primefactors, factors, fact;
bool isPowerTwo(long long int x) { return (x && !(x & (x - 1))); }
long long int power(long long int a, long long int b) {
  long long int r = 1;
  while (b) {
    if (b & 1) r = (r * a);
    a = (a * a);
    b >>= 1;
  }
  return r;
}
long long int powerM(long long int a, long long int b) {
  long long int r = 1;
  while (b) {
    if (b & 1) r = (r * a) % M;
    a = (a * a) % M;
    b >>= 1;
  }
  return r;
}
void getFactorial(long long int n) {
  fact.push_back(1);
  for (long long int i = 1; i <= n; i++)
    fact.push_back((i * 1ll * fact[i - 1]) % M);
}
bool isPrime(long long int n) {
  if (n < 2) return false;
  for (long long int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long int modi(long long int a) {
  long long int m = M, s = 1, p = 0;
  while (a > 1) {
    long long int q = a / m, t = m;
    m = a % m;
    a = t;
    t = p;
    p = s - q * p;
    s = t;
  }
  return s >= 0 ? s : s + M;
}
void getFactors(long long int n) {
  factors.clear();
  for (long long int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      factors.push_back(i);
      if (n / i != i) factors.push_back(n / i);
    }
  }
  sort(factors.begin(), factors.end());
}
long long int add(long long int a, long long int b) {
  return ((a % M) + (b % M) + M) % M;
}
long long int sub(long long int a, long long int b) {
  return ((a % M) - (b % M) + M) % M;
}
long long int mul(long long int a, long long int b) {
  return ((a % M) * (b % M)) % M;
}
void getPrimeFactors(long long int n) {
  primefactors.clear();
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      primefactors.push_back(i);
      while (n % i == 0) n = n / i;
    }
  }
  if (n != 1) primefactors.push_back(n);
}
bool isSubstring(string s1, string s2) {
  if (s1.find(s2) != string::npos)
    return true;
  else
    return false;
}
long long int ncr(long long int n, long long int r) {
  if (r == 0) return 1;
  fact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % M;
  return (fact[n] * modi(fact[r]) % M * modi(fact[n - r]) % M) % M;
}
long long int smallestPrimeDivisor(long long int n) {
  if (n % 2 == 0) return 2;
  for (long long int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return i;
  }
  return n;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int n, ans = 0;
  cin >> n;
  while (n) {
    if (n % 2 == 0) {
      ans += n / 2;
      n = 0;
    } else {
      n -= smallestPrimeDivisor(n);
      ans += 1;
    }
  }
  cout << ans;
  return 0;
}
