#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, p[10000000 + 5], pn, u[10000000 + 5], mu[10000000 + 5],
    phi[10000000 + 5], a[10000000 + 5], b[10000000 + 5];
long long ans, S, cnt;
bool cmp(int a, int b) { return u[a] < u[b]; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int main() {
  n = read();
  for (int i = 2; i <= n; ++i) {
    if (!u[i]) p[++pn] = u[i] = i, mu[i] = -1, phi[i] = i - 1;
    for (int j = 1; i * p[j] <= n; ++j) {
      u[i * p[j]] = p[j];
      if (i % p[j])
        mu[i * p[j]] = -mu[i], phi[i * p[j]] = phi[i] * (p[j] - 1);
      else {
        phi[i * p[j]] = phi[i] * p[j];
        break;
      }
    }
    a[i] = i;
    ans += i - 1 - phi[i];
  }
  for (int i = 1; i <= pn; ++i)
    if (p[i] > n / 2) ++cnt;
  ans += 3 * (1LL * (n - 1) * (n - 2) / 2 - ans - cnt * (n - 1 - cnt) -
              cnt * (cnt - 1) / 2);
  sort(a + 2, a + n + 1, cmp);
  for (int i = 2; i <= n; ++i) b[a[i]] = i;
  for (int i = 2; i <= n; ++i) {
    int l = 2, r = n, mid, s = 0;
    while (l <= r)
      if (1LL * u[a[mid = l + r >> 1]] * u[i] > n)
        r = mid - 1;
      else
        s = mid - 1, l = mid + 1;
    S += s;
  }
  for (int i = 2; i <= n; ++i)
    S += (1LL * (n / i) * (n / i) - (1LL * i * i > n && u[i] == i)) * mu[i];
  printf("%I64d", ans - S / 2);
  return 0;
}
