#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:536870912")
#pragma warning(disable : 4996)
using namespace std;
const int N = 1e7 + 100;
int s[N], phi[N], q[N], h[N];
int main() {
  for (int i = 2; i < N; i++) {
    if (!s[i]) {
      s[i] = i;
      for (long long int j = i * (long long int)i; j < N; j += i)
        if (!s[j]) s[j] = i;
    }
  }
  int n;
  scanf("%d", &n);
  long long int ans = 0;
  int t = 0, sq = 0;
  for (int i = 2; i <= n; i++) {
    if (s[i] == i)
      phi[i] = i - 1;
    else {
      phi[i] = phi[i / s[i]] * s[i];
      if (i / s[i] % s[i]) phi[i] -= phi[i] / s[i];
    }
    if (s[i] * 2 <= n) t++;
    if (s[i] * (long long int)s[i] <= n) ans++;
    q[s[i]]++;
    h[n / s[i]]++;
  }
  for (int i = 2, sum = 0; i <= n; i++) {
    sum += q[i];
    ans -= sum * (long long int)h[i];
  }
  ans /= 2;
  for (int i = 1; i <= n; i++) ans -= i - 1 - phi[i];
  ans += t * (t - 1ll) / 2 * 3;
  printf("%lld", ans);
  return 0;
}
