#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 5;
int prime[maxn], cnt, phi[maxn], divide[maxn], p[maxn], pp[maxn];
void sieve() {
  cnt = 0;
  phi[1] = 1;
  for (int i = 2; i < maxn; ++i) {
    if (!p[i]) {
      prime[cnt++] = i;
      phi[i] = i - 1;
      p[i] = i;
      divide[i] = 1;
    }
    for (int j = 0; j < cnt && i * prime[j] < maxn; ++j) {
      int k = i * prime[j];
      p[k] = prime[j];
      if (i % prime[j]) {
        phi[k] = phi[i] * (prime[j] - 1);
        divide[k] = divide[i] + 1;
      } else {
        phi[k] = phi[i] * prime[j];
        divide[k] = divide[i];
        break;
      }
    }
  }
}
long long cal0(int n) {
  long long ret = n - 1;
  int num = 0;
  for (int i = n / 2 + 1; i <= n; ++i) {
    if (p[i] == i)
      ret += i - 2, ++num;
    else
      ret += num;
  }
  return ret;
}
long long cal1(int n) {
  long long ret = 0;
  for (int i = 2; i <= n; ++i) ret += i - 1 - phi[i];
  return ret;
}
long long cal2(int n) {
  long long ret = 0;
  int num = 0;
  for (int i = 2; i <= n; ++i) {
    if (p[i] == i)
      ++num;
    else
      ret += phi[i] - 1 - num + divide[i], ++pp[p[i]];
  }
  for (int i = 1; i <= n; ++i) pp[i] += pp[i - 1];
  for (int i = 0; i < cnt && prime[i] <= n; ++i) {
    int q = prime[i];
    ret += pp[n / q];
    for (int j = q << 1; j <= n; j += q)
      if (p[j] <= n / q) --ret;
  }
  for (int i = 1; i <= n; ++i) pp[i] = pp[i - 1] + (p[i] == i ? 1 : 0);
  for (int i = 0; i < cnt && prime[i] <= n; ++i)
    ret += pp[min(prime[i] - 1, n / prime[i])];
  return ret;
}
int main() {
  sieve();
  int n;
  cin >> n;
  long long t0 = cal0(n), t1 = cal1(n), t2 = cal2(n);
  long long t3 = (n - 1LL) * n / 2 - t0 - t1 - t2;
  cout << t1 + 2 * t2 + 3 * t3 << endl;
  return 0;
}

### Prompt

Generate 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 + 5;
int prime[maxn], cnt, phi[maxn], divide[maxn], p[maxn], pp[maxn];
void sieve() {
  cnt = 0;
  phi[1] = 1;
  for (int i = 2; i < maxn; ++i) {
    if (!p[i]) {
      prime[cnt++] = i;
      phi[i] = i - 1;
      p[i] = i;
      divide[i] = 1;
    }
    for (int j = 0; j < cnt && i * prime[j] < maxn; ++j) {
      int k = i * prime[j];
      p[k] = prime[j];
      if (i % prime[j]) {
        phi[k] = phi[i] * (prime[j] - 1);
        divide[k] = divide[i] + 1;
      } else {
        phi[k] = phi[i] * prime[j];
        divide[k] = divide[i];
        break;
      }
    }
  }
}
long long cal0(int n) {
  long long ret = n - 1;
  int num = 0;
  for (int i = n / 2 + 1; i <= n; ++i) {
    if (p[i] == i)
      ret += i - 2, ++num;
    else
      ret += num;
  }
  return ret;
}
long long cal1(int n) {
  long long ret = 0;
  for (int i = 2; i <= n; ++i) ret += i - 1 - phi[i];
  return ret;
}
long long cal2(int n) {
  long long ret = 0;
  int num = 0;
  for (int i = 2; i <= n; ++i) {
    if (p[i] == i)
      ++num;
    else
      ret += phi[i] - 1 - num + divide[i], ++pp[p[i]];
  }
  for (int i = 1; i <= n; ++i) pp[i] += pp[i - 1];
  for (int i = 0; i < cnt && prime[i] <= n; ++i) {
    int q = prime[i];
    ret += pp[n / q];
    for (int j = q << 1; j <= n; j += q)
      if (p[j] <= n / q) --ret;
  }
  for (int i = 1; i <= n; ++i) pp[i] = pp[i - 1] + (p[i] == i ? 1 : 0);
  for (int i = 0; i < cnt && prime[i] <= n; ++i)
    ret += pp[min(prime[i] - 1, n / prime[i])];
  return ret;
}
int main() {
  sieve();
  int n;
  cin >> n;
  long long t0 = cal0(n), t1 = cal1(n), t2 = cal2(n);
  long long t3 = (n - 1LL) * n / 2 - t0 - t1 - t2;
  cout << t1 + 2 * t2 + 3 * t3 << endl;
  return 0;
}

```