#include <bits/stdc++.h>
using namespace std;
const int NMAX = 11000000;
int N, cnt[NMAX], tot;
long long ans;
int notPrime[NMAX], leN[NMAX];
int facP[NMAX], phi[NMAX];
vector<int> prime;
void genPrime(int n) {
  int i, j;
  notPrime[1] = 1;
  for (i = 2; i <= n; i += 1) {
    if (!notPrime[i]) {
      prime.push_back(i);
      phi[i] = i - 1;
      facP[i] = 1;
    }
    for (j = 0; j < prime.size() && i * prime[j] <= n; j += 1) {
      notPrime[i * prime[j]] = prime[j];
      facP[i * prime[j]] = facP[i];
      if (!(i % prime[j])) {
        phi[i * prime[j]] = prime[j] * phi[i];
        break;
      } else {
        phi[i * prime[j]] = (prime[j] - 1) * phi[i];
        facP[i * prime[j]] += 1;
      }
    }
  }
}
int main() {
  int i, preP, gtHalfN, pos, delta;
  scanf("%d", &N);
  genPrime(N);
  for (i = 2, pos = N, delta = prime.size(); i <= N; i += 1) {
    if (!notPrime[i]) {
      while (pos && (notPrime[pos] || (long long)i * pos > N)) {
        if (!notPrime[pos]) delta -= 1;
        pos -= 1;
      }
      leN[i] = delta;
    } else
      leN[i] = leN[notPrime[i]];
  }
  for (i = 2, pos = prime.back(), preP = gtHalfN = 0; i <= N; i += 1) {
    ans += i - 1 - phi[i];
    if (notPrime[i]) {
      ans += (phi[i] - (preP - facP[i]) - 1) * 2;
      delta = min(preP, leN[i]) - facP[i];
      ans += delta * 2;
      ans += (preP - delta - gtHalfN - facP[i]) * 3;
      if (notPrime[i] <= pos) {
        cnt[notPrime[i]] += 1;
        tot += 1;
      }
    } else {
      while (pos && (notPrime[pos] || (long long)i * pos > N)) {
        if (!notPrime[pos]) tot -= cnt[pos];
        pos -= 1;
      }
      if ((i << 1) <= N) {
        ans += (delta = min(leN[i], preP)) * 2;
        ans += tot * 2;
        ans += (phi[i] - delta - tot - 1 - gtHalfN) * 3;
      }
      preP += 1;
      if ((i << 1) > N) gtHalfN += 1;
    }
  }
  printf("%I64d\n", ans);
  exit(0);
}

### Prompt

Please create a solution in cpp 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 NMAX = 11000000;
int N, cnt[NMAX], tot;
long long ans;
int notPrime[NMAX], leN[NMAX];
int facP[NMAX], phi[NMAX];
vector<int> prime;
void genPrime(int n) {
  int i, j;
  notPrime[1] = 1;
  for (i = 2; i <= n; i += 1) {
    if (!notPrime[i]) {
      prime.push_back(i);
      phi[i] = i - 1;
      facP[i] = 1;
    }
    for (j = 0; j < prime.size() && i * prime[j] <= n; j += 1) {
      notPrime[i * prime[j]] = prime[j];
      facP[i * prime[j]] = facP[i];
      if (!(i % prime[j])) {
        phi[i * prime[j]] = prime[j] * phi[i];
        break;
      } else {
        phi[i * prime[j]] = (prime[j] - 1) * phi[i];
        facP[i * prime[j]] += 1;
      }
    }
  }
}
int main() {
  int i, preP, gtHalfN, pos, delta;
  scanf("%d", &N);
  genPrime(N);
  for (i = 2, pos = N, delta = prime.size(); i <= N; i += 1) {
    if (!notPrime[i]) {
      while (pos && (notPrime[pos] || (long long)i * pos > N)) {
        if (!notPrime[pos]) delta -= 1;
        pos -= 1;
      }
      leN[i] = delta;
    } else
      leN[i] = leN[notPrime[i]];
  }
  for (i = 2, pos = prime.back(), preP = gtHalfN = 0; i <= N; i += 1) {
    ans += i - 1 - phi[i];
    if (notPrime[i]) {
      ans += (phi[i] - (preP - facP[i]) - 1) * 2;
      delta = min(preP, leN[i]) - facP[i];
      ans += delta * 2;
      ans += (preP - delta - gtHalfN - facP[i]) * 3;
      if (notPrime[i] <= pos) {
        cnt[notPrime[i]] += 1;
        tot += 1;
      }
    } else {
      while (pos && (notPrime[pos] || (long long)i * pos > N)) {
        if (!notPrime[pos]) tot -= cnt[pos];
        pos -= 1;
      }
      if ((i << 1) <= N) {
        ans += (delta = min(leN[i], preP)) * 2;
        ans += tot * 2;
        ans += (phi[i] - delta - tot - 1 - gtHalfN) * 3;
      }
      preP += 1;
      if ((i << 1) > N) gtHalfN += 1;
    }
  }
  printf("%I64d\n", ans);
  exit(0);
}

```