#include <bits/stdc++.h>
using namespace std;
int Phi[10000002], N, MinP[10000005], number, Nb[10000005], Ind[10000005],
    Prime[10000005], Partial[10000005], cnt;
void Eratostene() {
  int i, j;
  for (i = 1; i <= N; i++) Phi[i] = i - 1;
  for (i = 2; i <= N; i++) {
    if (MinP[i] == 0) {
      Prime[++cnt] = i;
      Nb[cnt] = 1;
      if (i <= N / 2) number = cnt;
    }
    for (j = i + i; j <= N; j += i) {
      Phi[j] -= Phi[i];
      if (MinP[i] == 0 && MinP[j] == 0) MinP[j] = i, Nb[cnt]++;
    }
  }
  for (int i = cnt; i >= 1; i--) {
    Partial[i] = Partial[i + 1] + Nb[i];
  }
}
void Solve() {
  long long ans = 1LL * (N - 1) * (N - 2);
  for (int i = 2; i <= N; i++) {
    ans -= (i - 1 - Phi[i]);
    if (MinP[i] == 0) continue;
    if (MinP[i / MinP[i]] == 0) {
      ++Ind[MinP[i]];
      if (i / MinP[i] != MinP[i]) ++Ind[i / MinP[i]];
    }
  }
  for (int i = 1; i <= cnt; i++) {
    int pos = Ind[Prime[i]];
    ans -= (1LL * Nb[i] * Partial[pos + 1]);
    if (Prime[Ind[Prime[i]]] < Prime[i]) ans++;
    if (max(pos + 1, i + 1) <= number) {
      ans +=
          (3LL * Nb[i] * (Partial[max(pos + 1, i + 1)] - Partial[number + 1]));
    }
  }
  cout << ans << "\n";
}
int main() {
  cin >> N;
  Eratostene();
  Solve();
  return 0;
}
