#include <bits/stdc++.h>
using namespace std;
const int Max_N(10000000 + 5);
int N, ps, P[Max_N], phi[Max_N], MinP[Max_N], V[Max_N];
bool Prime[Max_N];
long long int Ans1, Ans2, Ans3, Tmp;
int main() {
  scanf("%d", &N);
  memset(Prime, true, sizeof(Prime)), Prime[0] = Prime[1] = false, phi[1] = 1;
  for (int i = 2; i <= N; ++i) {
    if (Prime[i]) P[++ps] = i, phi[i] = i - 1, MinP[i] = i;
    for (int j = 1; j <= ps && i * P[j] <= N; ++j) {
      Prime[i * P[j]] = false;
      MinP[i * P[j]] = P[j];
      if (i % P[j])
        phi[i * P[j]] = phi[i] * phi[P[j]];
      else {
        phi[i * P[j]] = phi[i] * P[j];
        break;
      }
    }
    Ans1 += i - 1 - phi[i], ++V[MinP[i]];
  }
  Tmp = V[1];
  for (int p = N, q = 1; p >= 1; --p) {
    while (p * (q + 1) <= N) Tmp += V[++q];
    Ans2 += V[p] * Tmp;
    if ((p * 1LL) * (p * 1LL) <= N) Ans2 -= V[p];
  }
  Ans2 /= 2LL;
  Tmp = 0LL;
  for (int p = 1; 2 * p <= N; ++p) {
    Tmp += V[p];
    Ans3 += V[p] * Tmp - ((V[p] * 1LL) * (V[p] - 1LL) / 2LL + V[p]);
  }
  printf("%I64d", Ans1 * 1LL + (Ans2 - Ans1) * 2LL + (Ans3 - Ans2) * 3LL);
  return 0;
}
