#include <bits/stdc++.h>
using namespace std;
inline int Read() {
  int x = 0, f = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 10000005;
int n, p_cnt, p[MAXN], phi[MAXN], minp[MAXN], cnt[MAXN];
inline long long Solve0() {
  int x = 1, cnt;
  while (x <= p_cnt && p[x] * 2 <= n) x++;
  cnt = p_cnt + 1 - x;
  return n - 1 + 1LL * cnt * (n - cnt - 1) + 1LL * cnt * (cnt - 1) / 2;
}
inline long long Solve1() {
  long long ret = 1LL * n * (n - 1) / 2;
  for (int i = 2; i <= n; i++) ret -= phi[i];
  return ret;
}
inline long long Solve2() {
  long long ret = 0;
  for (int i = 2; i <= n; i++) cnt[minp[i]]++;
  for (int i = 2; i <= n; i++) cnt[i] += cnt[i - 1];
  for (int i = 2, j = n; i <= n; i++) {
    while (i * j > n) j--;
    if (i > j) break;
    ret += 1LL * (cnt[i] - cnt[i - 1]) * (cnt[j] - cnt[i]) +
           1LL * (cnt[i] - cnt[i - 1] - 1) * (cnt[i] - cnt[i - 1]) / 2;
  }
  return ret;
}
int main() {
  n = Read();
  if (n == 1) return puts("0"), 0;
  for (int i = 2; i <= n; i++) {
    if (!minp[i]) p[++p_cnt] = minp[i] = i, phi[i] = i - 1;
    for (int j = 1; i * p[j] <= n; j++) {
      minp[i * p[j]] = min(minp[i], p[j]);
      phi[i * p[j]] = phi[i] * (p[j] - 1);
      if (i % p[j] == 0) {
        phi[i * p[j]] = phi[i] * p[j];
        break;
      }
    }
  }
  long long ans0 = Solve0(), ans1 = Solve1(), ans2 = Solve2() - ans1,
            ans3 = 1LL * n * (n - 1) / 2 - ans0 - ans1 - ans2;
  cout << ans1 + ans2 * 2 + ans3 * 3 << endl;
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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;
inline int Read() {
  int x = 0, f = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 10000005;
int n, p_cnt, p[MAXN], phi[MAXN], minp[MAXN], cnt[MAXN];
inline long long Solve0() {
  int x = 1, cnt;
  while (x <= p_cnt && p[x] * 2 <= n) x++;
  cnt = p_cnt + 1 - x;
  return n - 1 + 1LL * cnt * (n - cnt - 1) + 1LL * cnt * (cnt - 1) / 2;
}
inline long long Solve1() {
  long long ret = 1LL * n * (n - 1) / 2;
  for (int i = 2; i <= n; i++) ret -= phi[i];
  return ret;
}
inline long long Solve2() {
  long long ret = 0;
  for (int i = 2; i <= n; i++) cnt[minp[i]]++;
  for (int i = 2; i <= n; i++) cnt[i] += cnt[i - 1];
  for (int i = 2, j = n; i <= n; i++) {
    while (i * j > n) j--;
    if (i > j) break;
    ret += 1LL * (cnt[i] - cnt[i - 1]) * (cnt[j] - cnt[i]) +
           1LL * (cnt[i] - cnt[i - 1] - 1) * (cnt[i] - cnt[i - 1]) / 2;
  }
  return ret;
}
int main() {
  n = Read();
  if (n == 1) return puts("0"), 0;
  for (int i = 2; i <= n; i++) {
    if (!minp[i]) p[++p_cnt] = minp[i] = i, phi[i] = i - 1;
    for (int j = 1; i * p[j] <= n; j++) {
      minp[i * p[j]] = min(minp[i], p[j]);
      phi[i * p[j]] = phi[i] * (p[j] - 1);
      if (i % p[j] == 0) {
        phi[i * p[j]] = phi[i] * p[j];
        break;
      }
    }
  }
  long long ans0 = Solve0(), ans1 = Solve1(), ans2 = Solve2() - ans1,
            ans3 = 1LL * n * (n - 1) / 2 - ans0 - ans1 - ans2;
  cout << ans1 + ans2 * 2 + ans3 * 3 << endl;
  return 0;
}

```