#include <bits/stdc++.h>
const int N = 10000050;
using namespace std;
inline int gi() {
  char ch = getchar();
  int x = 0, q = 0;
  while (ch < '0' || ch > '9') ch == '-' ? q = 1 : 0, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return q ? (-x) : x;
}
int n, mu[N], mark[N], pri[N], phi[N], tot, low[N], t[N];
long long ans, sum;
inline void pre() {
  for (int i = 2, s; i <= n; ++i) {
    if (!mark[i]) pri[low[i] = ++tot] = i, phi[i] = i - 1, mu[i] = -1;
    for (int j = 1; j <= tot && (s = pri[j] * i) <= n; ++j) {
      mark[s] = 1;
      if (i % pri[j] == 0) {
        phi[s] = phi[i] * pri[j], mu[s] = 0;
        low[s] = low[i];
        break;
      } else {
        low[s] = (low[i] < j ? low[i] : j), mu[s] = -mu[i];
        phi[s] = phi[i] * (pri[j] - 1);
      }
    }
  }
  return;
}
int main() {
  cin >> n;
  pre();
  int s = 0;
  for (int i = 2; i <= n; ++i) {
    if ((pri[low[i]] << 1) > n) ++s;
    ans += i - phi[i] - 1;
    ++t[low[i]];
  }
  ans += (1ll * (n - 1) * (n - 2) / 2 - ans - 1ll * s * (n - s - 1) -
          1ll * (s) * (s - 1) / 2) *
         3;
  for (int i = 2; i <= tot; ++i) t[i] += t[i - 1];
  for (int i = 1, j = tot; i <= n; ++i) {
    for (; j && 1ll * pri[j] * pri[i] > n; --j)
      ;
    sum += 1ll * t[j] * (t[i] - t[i - 1]);
  }
  for (int i = 2; i <= n; ++i)
    sum += (1ll * (n / i) * (n / i) - (pri[low[i]] == i && 1ll * i * i > n)) *
           mu[i];
  cout << ans - sum / 2;
  return 0;
}
