#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 10;
int n, prime[N], phi[N], u[N], Min[N], cnt;
bool isp[N];
long long C2(long long n) { return n * (n - 1) / 2; }
long long d0() {
  int m = 1;
  for (int i = 1; i <= cnt; i++)
    if (prime[i] * 2 > n) m++;
  return 1ll * m * (n - 1) - C2(m);
}
long long d1() {
  long long ans = C2(n);
  for (int i = 1; i <= n; i++) ans -= phi[i];
  return ans + 1;
}
int q[N], size;
long long calc(int d) {
  long long ans = 0;
  size = 0;
  for (int i = max(d, 2); i <= n; i += d) q[++size] = Min[i];
  sort(q + 1, q + size + 1);
  for (int i = 1, j = size; i <= size; i++) {
    while ((long long)q[i] * q[j] > n) j--;
    ans += j;
    if ((long long)q[i] * q[i] <= n) ans--;
  }
  return ans / 2;
}
long long d2() {
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (u[i]) ans += u[i] * calc(i);
  return ans;
}
int main() {
  scanf("%d", &n);
  phi[1] = u[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!isp[i]) {
      prime[++cnt] = i;
      phi[i] = i - 1;
      Min[i] = i;
      u[i] = -1;
    }
    for (int j = 1; j <= cnt && i * prime[j] <= n; j++) {
      int x = i * prime[j];
      isp[x] = 1;
      Min[x] = prime[j];
      if (i % prime[j]) {
        phi[x] = phi[i] * (prime[j] - 1);
        u[x] = -u[i];
      } else {
        phi[x] = phi[i] * prime[j];
        u[x] = 0;
        break;
      }
    }
  }
  long long a0 = d0(), a1 = d1(), a2 = d2(), a3 = C2(n) - a0 - a1 - a2;
  printf("%lld\n", a1 + a2 * 2 + a3 * 3);
  return 0;
}
