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 int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b & 1) {
      ans = ((ans % 1073741824) * (a % 1073741824)) % 1073741824;
    }
    a = ((a % 1073741824) * (a % 1073741824)) % 1073741824;
    b = b >> 1;
  }
  return ans;
}
long long int powe(long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b & 1) {
      ans = a * ans;
    }
    a = a * a;
    b = b >> 1;
  }
  return ans;
}
long long int ncr(long long int n, long long int r) {
  r = ((r < n - r) ? (r) : (n - r));
  long long int ans = 1;
  for (int i = 0; i < r; i++) {
    ans *= (n - i);
    ans /= (i + 1);
  }
  return ans;
}
struct BIT {
 public:
  long long int *tree;
  long long int size;
  BIT(long long int n) {
    tree = new long long int[n + 1];
    size = n;
    for (int i = 0; i <= n; i++) {
      tree[i] = 0;
    }
  }
  long long int sum(long long int index) {
    index += 1;
    long long int sum = 0;
    while (index > 0) {
      sum += tree[index];
      index -= (index & (-index));
    }
    return sum;
  }
  void update(long long int index, long long int val) {
    index += 1;
    while (index <= size) {
      tree[index] += val;
      index += (index & (-index));
    }
  }
};
void solve() {
  long long int n;
  cin >> n;
  long long int ans = 0;
  for (long long int i = 2; i * i <= n; i += 1) {
    while (n > 0 && i == 2 && n % i == 0) {
      ans += n / i;
      n = n % i;
    }
    if (n > 0 && i > 2 && n % i == 0) {
      n -= i;
      ans++;
      i = 0;
    }
  }
  if (n > 1) {
    ans++;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t > 0) {
    solve();
    t--;
  }
}
