#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 5;
int n;
int lp[N], a[N], phi[N];
long long pre[N];
vector<int> pr;
void calc() {
  phi[1] = 1;
  for (int i = 2; i < N; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      phi[i] = i - 1;
      pr.push_back(i);
    } else {
      if (lp[i] == lp[i / lp[i]])
        phi[i] = phi[i / lp[i]] * lp[i];
      else
        phi[i] = phi[i / lp[i]] * (lp[i] - 1);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] < N; ++j)
      lp[i * pr[j]] = pr[j];
  }
}
int main() {
  scanf("%d", &n);
  calc();
  long long dec = 0;
  for (int i = 2; i <= n; i++) dec += i - 1 - phi[i];
  for (int i = 2; i <= n; i++) pre[lp[i]]++;
  for (int i = 2; i <= n; i++) pre[i] += pre[i - 1];
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    ans += pre[n / lp[i]];
    if ((long long)lp[i] * lp[i] <= n) ans--;
  }
  ans -= dec;
  for (int i = 2; i <= n; i++) {
    if (lp[i] == i and i * 2 <= n) {
      int r = i - 1;
      int l = n / i + 1;
      if (l <= r) ans += (pre[r] - pre[l - 1]) * 3;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
