#include <bits/stdc++.h>
using namespace std;
void Freopen() {
  freopen(
      "title"
      ".in",
      "r", stdin);
  freopen(
      "title"
      ".out",
      "w", stdout);
}
int read() {
  int g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
const int N = 1e7 + 5;
bool vis[N];
int p[N / 10], mn[N], smu[N], st[N], sst[N], mu[N];
int n;
long long ans1, ans2, ans3;
void init() {
  smu[1] = 1;
  for (int i = (2); i <= (n); i++) {
    if (!vis[i]) p[++p[0]] = i, mu[i] = -1, mn[i] = i, st[i]++;
    for (int j = 1; j <= p[0] && i * p[j] <= n; j++) {
      mn[i * p[j]] = p[j], st[p[j]]++;
      vis[i * p[j]] = 1;
      if (!(i % p[j])) break;
      mu[i * p[j]] = -mu[i];
    }
    smu[i] = smu[i - 1] + mu[i];
  }
  for (int i = (1); i <= (n); i++) sst[i] = sst[i - 1] + st[i];
}
long long calc(int x) { return 1ll * x * x; }
signed main() {
  n = read();
  init();
  long long re1 = 0;
  for (int l = 1, r; l <= n; l = r + 1) {
    r = n / (n / l);
    re1 += 1ll * (smu[r] - smu[l - 1]) * calc(n / l);
  }
  ans1 = (1ll * n * n - (n - 1) - re1) / 2;
  long long re2 = 0;
  for (int i = (1); i <= (n / 2); i++)
    re2 += 1ll * st[i] * sst[min(n / i, n / 2)];
  for (int i = 1; i * i <= n; i++) re2 -= st[i];
  re2 /= 2;
  re2 -= ans1;
  ans2 = re2;
  long long re3 = 1ll * sst[n / 2] * sst[n / 2];
  for (int i = (1); i <= (n / 2); i++) re3 -= st[i];
  re3 /= 2;
  re3 -= ans2 + ans1;
  ans3 = re3;
  cout << ans1 + 2 * ans2 + 3 * ans3;
  return signed();
}
