#include <bits/stdc++.h>
using namespace std;
long long n, m, nn, mm;
signed phi[10000005];
signed p[10000005];
signed a[10000005], r[10000005], c[10000005];
bool isp[10000005];
long long ans;
void QAQ() {
  mm = n;
  isp[1] = 1;
  for (long long i = 2; i <= n; i++) {
    if (isp[i] == 0) {
      nn++;
      p[nn] = i;
      a[i] = i;
      if (i * 2 > n) {
        mm--;
      }
    }
    for (long long j = 1; j <= nn; j++) {
      if (i * p[j] > n) break;
      isp[i * p[j]] = 1;
      a[i * p[j]] = p[j];
      if (i % p[j] == 0) break;
    }
  }
  for (long long i = 2; i <= n; i++) c[a[i]]++;
  phi[1] = 1;
  for (long long i = 2; i <= n; i++) {
    if (!isp[i]) {
      phi[i] = i - 1;
      continue;
    }
    if ((i / a[i]) % a[i] == 0)
      phi[i] = phi[i / a[i]] * (a[i]);
    else
      phi[i] = phi[i / a[i]] * (a[i] - 1);
  }
  for (long long i = 1; i <= n; i++) c[i] += c[i - 1];
}
long long QwQ(long long l, long long r) {
  if (r < l) return 0;
  return c[r] - c[l - 1];
}
signed main() {
  cin >> n;
  QAQ();
  long long fk = 0, md;
  for (long long i = 2; i <= n; i++) {
    fk += 1ll * (phi[i] - 1);
  }
  md = ((n - 1) * (n - 2)) >> 1;
  md -= fk;
  ans = fk * 2 + md;
  long long cnt = 0;
  for (long long i = 1; i <= nn; i++) {
    ;
    long long yy = 1ll * (c[p[i]] - c[p[i] - 1]);
    ans += 1ll * yy *
           QwQ(max(1ll * (p[i] + 1), n / p[i] + 1),
               max(1ll * (p[i] + 1), (n >> 1) + 1) - 1);
    ans -= 2 * yy * QwQ(max(1ll * (p[i] + 1), (n >> 1) + 1), n);
  }
  cout << ans;
  return 0;
}
