#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 10;
int n;
int mu[maxn], pri[700010], cnt, mf[maxn];
int c[700010], sum[700010];
bool vis[maxn];
void Linearmu() {
  mu[1] = 1;
  mf[1] = 0;
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) {
      mu[i] = -1;
      mf[i] = ++cnt;
      pri[cnt] = i;
    }
    for (int j = 1; j <= cnt; ++j) {
      if ((long long)i * pri[j] > n) break;
      vis[i * pri[j]] = true;
      mf[i * pri[j]] = j;
      if (i % pri[j] == 0) {
        mu[i * pri[j]] = 0;
        break;
      } else
        mu[i * pri[j]] = -mu[i];
    }
  }
}
long long F(int x) { return 1LL * x * (x - 1) / 2; }
int main() {
  scanf("%d", &n);
  Linearmu();
  long long a1 = 0, a0 = 0, a2 = 0, a3 = 0, tmp = 0;
  for (int i = 2; i <= n && n / i > 1; ++i)
    if (mu[i]) a1 += F(n / i) * (-mu[i]);
  int num = 0;
  for (int i = 1; i <= n; ++i) {
    if (i == 1 || (2 * i > n && !vis[i])) {
      a0 += i - 1;
      num++;
    } else
      a0 += num;
  }
  for (int i = 1; i <= n; ++i)
    if (mu[i]) {
      tmp = 0;
      if (i <= 1000) {
        int mx = 0;
        for (int j = i; j <= n; j += i) mx = max(mx, mf[j]);
        for (int j = 0; j <= mx; ++j) c[j] = 0;
        for (int j = i; j <= n; j += i) c[mf[j]]++;
        sum[0] = c[0];
        for (int j = 1; j <= mx; ++j) sum[j] = sum[j - 1] + c[j];
        int r = mx;
        for (int j = 0; j <= mx; ++j)
          if (c[j]) {
            while (r >= 0 && (long long)pri[r] * pri[j] > n) r--;
            if (r >= 0) tmp += (long long)c[j] * sum[r];
          }
      } else {
        int now = 0;
        for (int j = i; j <= n; j += i) c[now++] = mf[j];
        sort(c, c + now);
        int r = now - 1;
        for (int j = 0; j < now; ++j) {
          while (r >= 0 && (long long)pri[c[r]] * pri[c[j]] > n) r--;
          tmp += r + 1;
        }
      }
      a2 += tmp * mu[i];
    }
  a2 = (a2 + 1) / 2 - n;
  a3 = 1LL * n * (n - 1) / 2 - a0 - a1 - a2;
  long long ans = a1 + a2 * 2 + a3 * 3;
  printf("%lld\n", 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;
const int maxn = 1e7 + 10;
int n;
int mu[maxn], pri[700010], cnt, mf[maxn];
int c[700010], sum[700010];
bool vis[maxn];
void Linearmu() {
  mu[1] = 1;
  mf[1] = 0;
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) {
      mu[i] = -1;
      mf[i] = ++cnt;
      pri[cnt] = i;
    }
    for (int j = 1; j <= cnt; ++j) {
      if ((long long)i * pri[j] > n) break;
      vis[i * pri[j]] = true;
      mf[i * pri[j]] = j;
      if (i % pri[j] == 0) {
        mu[i * pri[j]] = 0;
        break;
      } else
        mu[i * pri[j]] = -mu[i];
    }
  }
}
long long F(int x) { return 1LL * x * (x - 1) / 2; }
int main() {
  scanf("%d", &n);
  Linearmu();
  long long a1 = 0, a0 = 0, a2 = 0, a3 = 0, tmp = 0;
  for (int i = 2; i <= n && n / i > 1; ++i)
    if (mu[i]) a1 += F(n / i) * (-mu[i]);
  int num = 0;
  for (int i = 1; i <= n; ++i) {
    if (i == 1 || (2 * i > n && !vis[i])) {
      a0 += i - 1;
      num++;
    } else
      a0 += num;
  }
  for (int i = 1; i <= n; ++i)
    if (mu[i]) {
      tmp = 0;
      if (i <= 1000) {
        int mx = 0;
        for (int j = i; j <= n; j += i) mx = max(mx, mf[j]);
        for (int j = 0; j <= mx; ++j) c[j] = 0;
        for (int j = i; j <= n; j += i) c[mf[j]]++;
        sum[0] = c[0];
        for (int j = 1; j <= mx; ++j) sum[j] = sum[j - 1] + c[j];
        int r = mx;
        for (int j = 0; j <= mx; ++j)
          if (c[j]) {
            while (r >= 0 && (long long)pri[r] * pri[j] > n) r--;
            if (r >= 0) tmp += (long long)c[j] * sum[r];
          }
      } else {
        int now = 0;
        for (int j = i; j <= n; j += i) c[now++] = mf[j];
        sort(c, c + now);
        int r = now - 1;
        for (int j = 0; j < now; ++j) {
          while (r >= 0 && (long long)pri[c[r]] * pri[c[j]] > n) r--;
          tmp += r + 1;
        }
      }
      a2 += tmp * mu[i];
    }
  a2 = (a2 + 1) / 2 - n;
  a3 = 1LL * n * (n - 1) / 2 - a0 - a1 - a2;
  long long ans = a1 + a2 * 2 + a3 * 3;
  printf("%lld\n", ans);
  return 0;
}

```