#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 5, M = 4e6 + 5;
int n, ct, f[N], k[N], q[N], fi[N], c[M];
long long sum = 0, ans = 0, tot[N];
int Max(int x, int y) { return x > y ? x : y; }
void Oula() {
  for (int i = 2; i <= n; i++) {
    if (!f[i]) k[i] = i, c[++ct] = i, fi[i] = i - 1;
    for (int j = 1; j <= ct && (long long)i * c[j] <= n; j++) {
      f[i * c[j]] = 1;
      k[i * c[j]] = (k[i] < c[j] ? k[i] : c[j]);
      if (i % c[j] == 0) {
        fi[i * c[j]] = fi[i] * c[j];
        break;
      } else
        fi[i * c[j]] = fi[i] * (c[j] - 1);
    }
    q[k[i]]++;
    sum += fi[i] - 1;
  }
  for (int i = 2; i <= n; i++) tot[i] = tot[i - 1] + q[i];
}
int main() {
  scanf("%d", &n);
  Oula();
  ans += (long long)(n - 1) * (n - 2) / 2;
  ans -= sum;
  for (int i = 2; i <= ct; i++) {
    int x = c[i];
    if (n / 2 < Max(x + 1, n / x + 1)) break;
    ans += (long long)(tot[n / 2] - tot[Max(x + 1, n / x + 1) - 1]) * q[x] * 3;
    sum -= (long long)(tot[n / 2] - tot[Max(x + 1, n / x + 1) - 1]) * q[x];
  }
  for (int i = 1; i <= ct; i++) {
    int x = c[i];
    if (n < Max(x + 1, n / 2 + 1)) break;
    sum -= (long long)(tot[n] - tot[Max(x + 1, n / 2 + 1) - 1]) * q[x];
  }
  ans += sum * 2;
  printf("%lld\n", ans);
  return 0;
}
