#include <bits/stdc++.h>
using namespace std;
int n, prin, dys;
int zx[10000005], pri[10000005], phi[10000005], miu[10000005], sm[10000005];
long long ans, sum;
inline int read() {
  int n = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    n = n * 10 + c - '0';
    c = getchar();
  }
  return n * f;
}
int main() {
  register int i, j;
  n = read();
  for (phi[1] = miu[1] = 1, i = 2; i <= n; ++i) {
    if (!zx[i]) pri[++prin] = i, zx[i] = prin, phi[i] = i - 1, miu[i] = -1;
    for (j = 1; i * pri[j] <= n; ++j) {
      zx[i * pri[j]] = j;
      if (i % pri[j] == 0) {
        phi[i * pri[j]] = phi[i] * pri[j];
        miu[i * pri[j]] = 0;
        break;
      } else {
        phi[i * pri[j]] = phi[i] * (pri[j] - 1);
        miu[i * pri[j]] = -miu[i];
      }
    }
    ans += i - phi[i] - 1;
    ++sm[zx[i]];
  }
  for (i = 1; i <= prin; ++i)
    if (pri[i] * 2 > n) ++dys;
  ans += (1LL * (n - 1) * (n - 2) / 2 - ans - 1LL * dys * (n - dys - 1) -
          1LL * dys * (dys - 1) / 2) *
         3;
  for (i = 1; i <= prin; ++i) sm[i] += sm[i - 1];
  for (i = 1, j = prin; i <= prin; ++i) {
    for (; j && pri[i] * pri[j] > n; --j)
      ;
    sum += 1LL * sm[j] * (sm[i] - sm[i - 1]);
  }
  for (i = 2; i <= n; ++i)
    sum += (1LL * (n / i) * (n / i) - (pri[zx[i]] == i && 1LL * i * i > n)) *
           miu[i];
  printf("%I64d", ans - sum / 2);
}
