#include <bits/stdc++.h>
using namespace std;
int n, i, j, tr[10000005], prime[10000005], phi[10000005], fac[10000005],
    cnt = 0, num;
long long ans = 0;
int lowbit(int p) { return p & -p; }
void insert(int p, int v) {
  while (p <= n) {
    tr[p] += v;
    p += lowbit(p);
  }
}
int ask(int p) {
  int ans = 0;
  while (p > 0) {
    ans += tr[p];
    p -= lowbit(p);
  }
  return ans;
}
int main() {
  cnt = 0;
  scanf("%d", &n);
  for (i = 2; i <= n; i++) {
    if (fac[i] == 0)
      fac[i] = i, phi[i] = i - 1, prime[++cnt] = i;
    else
      phi[i] = (i / fac[i] % fac[i] == 0) ? phi[i / fac[i]] * fac[i]
                                          : phi[i / fac[i]] * (fac[i] - 1);
    for (j = 1; prime[j] <= fac[i] && i * prime[j] <= n && j <= cnt; j++)
      fac[i * prime[j]] = prime[j];
    num = ask(n / fac[i]);
    ans += num * 2 - i + 1 + phi[i] +
           3 * ((2 * fac[i] <= n) ? ask(n / 2) - num : 0);
    insert(fac[i], 1);
  }
  printf("%lld", ans);
  return 0;
}

### 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 n, i, j, tr[10000005], prime[10000005], phi[10000005], fac[10000005],
    cnt = 0, num;
long long ans = 0;
int lowbit(int p) { return p & -p; }
void insert(int p, int v) {
  while (p <= n) {
    tr[p] += v;
    p += lowbit(p);
  }
}
int ask(int p) {
  int ans = 0;
  while (p > 0) {
    ans += tr[p];
    p -= lowbit(p);
  }
  return ans;
}
int main() {
  cnt = 0;
  scanf("%d", &n);
  for (i = 2; i <= n; i++) {
    if (fac[i] == 0)
      fac[i] = i, phi[i] = i - 1, prime[++cnt] = i;
    else
      phi[i] = (i / fac[i] % fac[i] == 0) ? phi[i / fac[i]] * fac[i]
                                          : phi[i / fac[i]] * (fac[i] - 1);
    for (j = 1; prime[j] <= fac[i] && i * prime[j] <= n && j <= cnt; j++)
      fac[i * prime[j]] = prime[j];
    num = ask(n / fac[i]);
    ans += num * 2 - i + 1 + phi[i] +
           3 * ((2 * fac[i] <= n) ? ask(n / 2) - num : 0);
    insert(fac[i], 1);
  }
  printf("%lld", ans);
  return 0;
}

```