#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 7;
bool flag[maxn];
int p[maxn], tot, phi[maxn], mi[maxn], delta[maxn], p_cnt[maxn];
int n;
void init() {
  flag[1] = 1;
  phi[1] = 0;
  delta[1] = 0;
  for (int i = 2; i < maxn; i++) {
    if (!flag[i]) {
      p[tot++] = i;
      phi[i] = i - 1;
      mi[i] = i;
      delta[i] = 1;
    }
    for (int j = 0; j < tot && 1LL * i * p[j] < maxn; j++) {
      flag[i * p[j]] = 1;
      mi[i * p[j]] = p[j];
      if (i % p[j] == 0) {
        phi[i * p[j]] = phi[i] * p[j];
        delta[i * p[j]] = delta[i];
        break;
      } else {
        phi[i * p[j]] = phi[i] * (p[j] - 1);
        delta[i * p[j]] = delta[i] + 1;
      }
    }
  }
  for (int i = 1; i < maxn; i++) {
    p_cnt[i] = p_cnt[i - 1] + (flag[i] == 0);
  }
}
long long com_com() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (flag[i] == 0) continue;
    ans += phi[i] - (p_cnt[i] - delta[i]) - 1;
  }
  return ans * 2;
}
long long pri_pri() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (flag[i] == 1) continue;
    int mx = n / i;
    mx = min(mx, i - 1);
    ans += p_cnt[mx];
  }
  return ans * 2;
}
long long pri_com() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (flag[i] == 0) continue;
    int mx = n / mi[i];
    ans += 2 * p_cnt[mx];
    ans -= 2 * delta[i];
  }
  return ans;
}
long long pri_pri3() {
  long long ans = 0;
  for (int i = 2; i <= n / 2; i++) {
    if (flag[i] == 1) continue;
    int L = (n + 1 + i - 1) / i;
    int R = min(n / 2, i - 1);
    if (R >= L) {
      int cnt = p_cnt[R] - p_cnt[L - 1];
      ans += 3 * cnt;
    }
  }
  return ans;
}
long long pri_com3() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (flag[i] == 0) continue;
    if (mi[i] * 2 > n) continue;
    int L = (n + mi[i]) / mi[i];
    int R = n / 2;
    if (R >= L) {
      ans += 3 * (p_cnt[R] - p_cnt[L - 1]);
    }
  }
  return ans;
}
int main() {
  cin >> n;
  init();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (i - 1 - phi[i]);
  }
  ans += com_com();
  ans += pri_pri();
  ans += pri_com();
  ans += pri_pri3();
  ans += pri_com3();
  cout << ans << endl;
  return 0;
}

### Prompt

Your task is to create 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 + 7;
bool flag[maxn];
int p[maxn], tot, phi[maxn], mi[maxn], delta[maxn], p_cnt[maxn];
int n;
void init() {
  flag[1] = 1;
  phi[1] = 0;
  delta[1] = 0;
  for (int i = 2; i < maxn; i++) {
    if (!flag[i]) {
      p[tot++] = i;
      phi[i] = i - 1;
      mi[i] = i;
      delta[i] = 1;
    }
    for (int j = 0; j < tot && 1LL * i * p[j] < maxn; j++) {
      flag[i * p[j]] = 1;
      mi[i * p[j]] = p[j];
      if (i % p[j] == 0) {
        phi[i * p[j]] = phi[i] * p[j];
        delta[i * p[j]] = delta[i];
        break;
      } else {
        phi[i * p[j]] = phi[i] * (p[j] - 1);
        delta[i * p[j]] = delta[i] + 1;
      }
    }
  }
  for (int i = 1; i < maxn; i++) {
    p_cnt[i] = p_cnt[i - 1] + (flag[i] == 0);
  }
}
long long com_com() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (flag[i] == 0) continue;
    ans += phi[i] - (p_cnt[i] - delta[i]) - 1;
  }
  return ans * 2;
}
long long pri_pri() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (flag[i] == 1) continue;
    int mx = n / i;
    mx = min(mx, i - 1);
    ans += p_cnt[mx];
  }
  return ans * 2;
}
long long pri_com() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (flag[i] == 0) continue;
    int mx = n / mi[i];
    ans += 2 * p_cnt[mx];
    ans -= 2 * delta[i];
  }
  return ans;
}
long long pri_pri3() {
  long long ans = 0;
  for (int i = 2; i <= n / 2; i++) {
    if (flag[i] == 1) continue;
    int L = (n + 1 + i - 1) / i;
    int R = min(n / 2, i - 1);
    if (R >= L) {
      int cnt = p_cnt[R] - p_cnt[L - 1];
      ans += 3 * cnt;
    }
  }
  return ans;
}
long long pri_com3() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (flag[i] == 0) continue;
    if (mi[i] * 2 > n) continue;
    int L = (n + mi[i]) / mi[i];
    int R = n / 2;
    if (R >= L) {
      ans += 3 * (p_cnt[R] - p_cnt[L - 1]);
    }
  }
  return ans;
}
int main() {
  cin >> n;
  init();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (i - 1 - phi[i]);
  }
  ans += com_com();
  ans += pri_pri();
  ans += pri_com();
  ans += pri_pri3();
  ans += pri_com3();
  cout << ans << endl;
  return 0;
}

```