#include <bits/stdc++.h>
using namespace std;
int psz, mu[10010000], vis[10010000], d[10010000], c[10010000], n,
    pri[10010000];
long long dis1 = 0, dis2 = 0, dis3 = 0, dis0 = 0;
int main() {
  scanf("%d", &n), mu[1] = c[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) {
      pri[++psz] = i, c[i] = i, mu[i] = -1;
    }
    for (int j = 1; j <= psz && pri[j] * i <= n; ++j) {
      vis[i * pri[j]] = 1;
      if (i % pri[j]) {
        mu[i * pri[j]] = -mu[i], c[i * pri[j]] = pri[j];
      } else {
        mu[i * pri[j]] = 0, c[i * pri[j]] = pri[j];
        break;
      }
    }
    if (!vis[i] && i > n / 2) dis0++;
    d[c[i]]++;
  }
  dis0 = dis0 * (n - dis0 - 1) + dis0 * (dis0 - 1) / 2;
  for (int i = 1; i <= n; ++i) d[i] += d[i - 1];
  for (int i = 1; i <= n; ++i)
    dis2 += 1ll * (d[i] - d[i - 1]) * d[n / i] - (1ll * c[i] * c[i] <= n);
  for (int i = 1; i <= n; ++i) dis1 += 1ll * mu[i] * (n / i) * (n / i);
  dis1 -= 2 * n - 1;
  dis1 = 1ll * (n - 1) * (n - 2) / 2 - dis1 / 2;
  dis2++;
  dis2 = dis2 / 2 - dis1;
  long long ans = dis1 * 1 + dis2 * 2 +
                  (1ll * (n - 1) * (n - 2) / 2 - dis1 - dis2 - dis0) * 3;
  printf("%lld", ans);
}

### Prompt

Develop a solution in CPP to the problem described below:

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;
int psz, mu[10010000], vis[10010000], d[10010000], c[10010000], n,
    pri[10010000];
long long dis1 = 0, dis2 = 0, dis3 = 0, dis0 = 0;
int main() {
  scanf("%d", &n), mu[1] = c[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) {
      pri[++psz] = i, c[i] = i, mu[i] = -1;
    }
    for (int j = 1; j <= psz && pri[j] * i <= n; ++j) {
      vis[i * pri[j]] = 1;
      if (i % pri[j]) {
        mu[i * pri[j]] = -mu[i], c[i * pri[j]] = pri[j];
      } else {
        mu[i * pri[j]] = 0, c[i * pri[j]] = pri[j];
        break;
      }
    }
    if (!vis[i] && i > n / 2) dis0++;
    d[c[i]]++;
  }
  dis0 = dis0 * (n - dis0 - 1) + dis0 * (dis0 - 1) / 2;
  for (int i = 1; i <= n; ++i) d[i] += d[i - 1];
  for (int i = 1; i <= n; ++i)
    dis2 += 1ll * (d[i] - d[i - 1]) * d[n / i] - (1ll * c[i] * c[i] <= n);
  for (int i = 1; i <= n; ++i) dis1 += 1ll * mu[i] * (n / i) * (n / i);
  dis1 -= 2 * n - 1;
  dis1 = 1ll * (n - 1) * (n - 2) / 2 - dis1 / 2;
  dis2++;
  dis2 = dis2 / 2 - dis1;
  long long ans = dis1 * 1 + dis2 * 2 +
                  (1ll * (n - 1) * (n - 2) / 2 - dis1 - dis2 - dis0) * 3;
  printf("%lld", ans);
}

```