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;
long long MOD = 1000000007;
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long power(long long x, unsigned long long y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
vector<long long> decToBinary(long long n) {
  vector<long long> v;
  for (long long i = 31; i >= 0; i--) {
    long long k = n >> i;
    if (k & 1)
      v.push_back(1);
    else
      v.push_back(0);
  }
  return v;
}
long long binarySearch(long long arr[], long long l, long long r, long long x) {
  if (r >= l) {
    long long mid = l + (r - l) / 2;
    if (arr[mid] == x) return mid;
    if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
    return binarySearch(arr, mid + 1, r, x);
  }
  return -1;
}
long long maxResult(long long n, long long a, long long b, long long c) {
  long long maxVal = 0;
  for (long long i = 0; i <= n; i += a)
    for (long long j = 0; j <= n - i; j += b) {
      float z = (float)(n - (i + j)) / c;
      if (floor(z) == ceil(z)) {
        long long x = i / a;
        long long y = j / b;
        maxVal = max(maxVal, x + y + (long long)z);
      }
    }
  return maxVal;
}
bool binary_search_vector(const vector<long long>& sorted_vec, long long key) {
  size_t mid, left = 0;
  size_t right = sorted_vec.size();
  while (left < right) {
    mid = left + (right - left) / 2;
    if (key > sorted_vec[mid]) {
      left = mid + 1;
    } else if (key < sorted_vec[mid]) {
      right = mid;
    } else {
      return true;
    }
  }
  return false;
}
void SeiveOfEratosthenes(long long n) {
  bool prime[n + 1];
  vector<long long> v;
  memset(prime, true, sizeof(prime));
  for (long long i = 2; i * i <= n; i++) {
    if (prime[i]) {
      for (long long j = i * i; j <= n; j += i) {
        prime[j] = false;
      }
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (prime[i]) {
      v.push_back(i);
    }
  }
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long smallestDivisor(long long n) {
  if (n % 2 == 0) return 2;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return i;
  }
  return n;
}
int32_t main() {
  long long n;
  cin >> n;
  long long cnt = 0;
  while (n > 0) {
    if (n % 2 == 0) {
      cnt += n / 2;
      break;
    }
    long long r = smallestDivisor(n);
    n = n - r;
    cnt++;
  }
  cout << cnt;
}
