#include <bits/stdc++.h>
using namespace std;
void init() {}
const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = (int)1e7 + 34;
const long long md = (long long)1e9 + 7;
bool u[N];
int prim[N / 4], plen;
int n;
int valid = 0;
long long num[N];
long long sf[N];
int nxp[N];
int rs[N];
inline int go(int x) {
  int xx = x;
  int p[10], m = 0;
  for (int i = 0; prim[i] * prim[i] <= x; i++) {
    if (x % prim[i]) continue;
    p[m++] = prim[i];
    while (x % prim[i] == 0) x /= prim[i];
  }
  if (x > 1) p[m++] = x;
  if (m == 1 && p[0] * 2 > n) return 0;
  num[p[0]]++;
  int res = 0;
  if (m == 1)
    res = n / p[0];
  else {
    int y = 1;
    for (int i = 0; i < m - 1; i++) y *= p[i];
    res = n / p[m - 1] + rs[y];
    y = p[m - 1];
    for (int msk = 1; msk < (1 << (m - 1)); msk++) {
      if (msk & 1)
        y *= p[0];
      else {
        y = p[m - 1];
        for (int i = 0; i < m - 1; i++)
          if (msk & (1 << i)) y *= p[i];
      }
      if (__builtin_popcount(msk) % 2)
        res -= n / y;
      else
        res += n / y;
    }
  }
  rs[xx] = res;
  res--;
  return (valid - res - 1) * 2 + res;
}
int main() {
  init();
  u[0] = u[1] = true;
  for (int i = 2; i < N; i++) {
    if (u[i]) continue;
    prim[plen++] = i;
    for (int j = i * 2; j < N; j += i) {
      u[j] = true;
    }
  }
  cin >> n;
  int nx = plen - 1;
  for (int i = 0; i < plen - 1; i++) {
    nx = max(nx, i + 1);
    while (nx - 1 > i && (long long)prim[i] * (long long)prim[nx - 1] > n) nx--;
    nxp[prim[i]] = prim[nx];
  }
  valid = n - 1;
  for (auto p : prim) {
    if (p <= n && p * 2 > n) valid--;
  }
  long long ans = 0;
  for (int i = 2; i <= n; i++) ans += go(i);
  ans /= 2;
  sf[n] = 0;
  for (int i = n - 1; i >= 0; i--) sf[i] = sf[i + 1] + num[i];
  long long cur = n - 1;
  long long lp = -1;
  for (int i = 0; i < plen; i++) {
    long long p = prim[i];
    if (p * 2 > n) continue;
    while (cur > 0 && p * (cur - 1) > n) {
      cur--;
      if (!u[cur]) lp = cur;
    }
    if (lp > p) {
      ans += num[p] * sf[lp];
    } else {
      ans += num[p] * sf[nxp[p]];
    }
  }
  cout << ans;
  return 0;
}

### Prompt

Please formulate a cpp solution to the following problem:

You are given a positive integer n. Let's build a graph on vertices 1, 2, ..., n in such a way that there is an edge between vertices u and v if and only if <image>. Let d(u, v) be the shortest distance between u and v, or 0 if there is no path between them. Compute the sum of values d(u, v) over all 1 ≤ u < v ≤ n.

The gcd (greatest common divisor) of two positive integers is the maximum positive integer that divides both of the integers.

Input

Single integer n (1 ≤ n ≤ 107).

Output

Print the sum of d(u, v) over all 1 ≤ u < v ≤ n.

Examples

Input

6


Output

8


Input

10


Output

44

Note

All shortest paths in the first example: 

  * <image>
  * <image>
  * <image>
  * <image>
  * <image>
  * <image>



There are no paths between other pairs of vertices.

The total distance is 2 + 1 + 1 + 2 + 1 + 1 = 8.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void init() {}
const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = (int)1e7 + 34;
const long long md = (long long)1e9 + 7;
bool u[N];
int prim[N / 4], plen;
int n;
int valid = 0;
long long num[N];
long long sf[N];
int nxp[N];
int rs[N];
inline int go(int x) {
  int xx = x;
  int p[10], m = 0;
  for (int i = 0; prim[i] * prim[i] <= x; i++) {
    if (x % prim[i]) continue;
    p[m++] = prim[i];
    while (x % prim[i] == 0) x /= prim[i];
  }
  if (x > 1) p[m++] = x;
  if (m == 1 && p[0] * 2 > n) return 0;
  num[p[0]]++;
  int res = 0;
  if (m == 1)
    res = n / p[0];
  else {
    int y = 1;
    for (int i = 0; i < m - 1; i++) y *= p[i];
    res = n / p[m - 1] + rs[y];
    y = p[m - 1];
    for (int msk = 1; msk < (1 << (m - 1)); msk++) {
      if (msk & 1)
        y *= p[0];
      else {
        y = p[m - 1];
        for (int i = 0; i < m - 1; i++)
          if (msk & (1 << i)) y *= p[i];
      }
      if (__builtin_popcount(msk) % 2)
        res -= n / y;
      else
        res += n / y;
    }
  }
  rs[xx] = res;
  res--;
  return (valid - res - 1) * 2 + res;
}
int main() {
  init();
  u[0] = u[1] = true;
  for (int i = 2; i < N; i++) {
    if (u[i]) continue;
    prim[plen++] = i;
    for (int j = i * 2; j < N; j += i) {
      u[j] = true;
    }
  }
  cin >> n;
  int nx = plen - 1;
  for (int i = 0; i < plen - 1; i++) {
    nx = max(nx, i + 1);
    while (nx - 1 > i && (long long)prim[i] * (long long)prim[nx - 1] > n) nx--;
    nxp[prim[i]] = prim[nx];
  }
  valid = n - 1;
  for (auto p : prim) {
    if (p <= n && p * 2 > n) valid--;
  }
  long long ans = 0;
  for (int i = 2; i <= n; i++) ans += go(i);
  ans /= 2;
  sf[n] = 0;
  for (int i = n - 1; i >= 0; i--) sf[i] = sf[i + 1] + num[i];
  long long cur = n - 1;
  long long lp = -1;
  for (int i = 0; i < plen; i++) {
    long long p = prim[i];
    if (p * 2 > n) continue;
    while (cur > 0 && p * (cur - 1) > n) {
      cur--;
      if (!u[cur]) lp = cur;
    }
    if (lp > p) {
      ans += num[p] * sf[lp];
    } else {
      ans += num[p] * sf[nxp[p]];
    }
  }
  cout << ans;
  return 0;
}

```