#include <bits/stdc++.h>
using namespace std;
const int N = 10000005;
const int inf = 1e9 + 7;
long long ans, a, b, c;
int ip[N], pr[2000005], pre[N], phi[N], pre2[N];
int n, tot;
inline long long Solve() {
  long long res = 0;
  for (int i = (n); i >= (1); i--) pre2[i] += pre2[i + 1];
  for (int i = (2); i <= (n / 2); i++)
    if (ip[i]) {
      int j = n / i + 1;
      if (j < i) res += pre2[j] - pre2[i];
    }
  return res;
}
int main() {
  scanf("%d", &n);
  if (n <= 3) {
    puts("0");
    return 0;
  }
  phi[1] = 1;
  for (int i = (2); i <= (n); i++) ip[i] = 1;
  for (int i = (2); i <= (n); i++) {
    if (ip[i]) {
      phi[i] = i - 1;
      pr[tot++] = i;
    }
    for (int j = 0; j < tot; j++) {
      if (1ll * pr[j] * i > (long long)n) break;
      ++pre[pr[j]];
      ip[i * pr[j]] = 0;
      if (i % pr[j] == 0) {
        phi[i * pr[j]] = phi[i] * pr[j];
        break;
      }
      phi[i * pr[j]] = phi[i] * phi[pr[j]];
    }
  }
  for (int i = (n); i >= (1); i--) pre[i] += pre[i + 1];
  for (int i = (2); i <= (n); i++) {
    if (ip[i] && i * 2 > n) continue;
    b++;
    a += i - phi[i] - 1;
    if (ip[i]) {
      pre2[i] = 1;
      c += pre[n / i + 1];
    }
  }
  printf("%lld\n", b * (b - 1) / 2ll * 2 + c + Solve() - a);
  return 0;
}
