#include <bits/stdc++.h>
using namespace std;
const int MX = 10000005;
int n, cnt = 0;
int phi[MX], lp[MX], om[MX], pref_lp[MX];
bool bad[MX];
int cnt_bad = 0;
void precomp() {
  for (int i = 1; i <= n; i++) phi[i] = i;
  for (int i = 2; i <= n; i++)
    if (!lp[i]) {
      for (int j = i; j <= n; j += i) {
        if (!lp[j]) lp[j] = i;
        phi[j] /= i;
        phi[j] *= (i - 1);
      }
    }
  for (int i = 1; i <= n; i++) {
    if (i == 1 || (lp[i] == i && 2 * i > n)) {
      bad[i] = 1;
      cnt_bad++;
    }
  }
  for (int i = 2; i <= n; i++) {
    if (lp[i] == i)
      om[i] = 1;
    else if (lp[i / lp[i]] == lp[i])
      om[i] = om[i / lp[i]];
    else
      om[i] = om[i / lp[i]] + 1;
  }
}
long long get_dist_one() {
  long long res = 0ll;
  for (int i = 2; i <= n; i++)
    if (!bad[i]) res += i - 1 - phi[i];
  return res;
}
long long get_dist_two() {
  long long res = 0ll;
  int prefprime = 1;
  for (int i = 2; i <= n; i++) {
    if (lp[i] != i)
      res += phi[i] + om[i] - prefprime;
    else
      prefprime++;
  }
  for (int i = 1; i <= n; i++)
    if (!bad[i]) pref_lp[lp[i]]++;
  for (int i = 1; i <= n; i++) pref_lp[i] += pref_lp[i - 1];
  for (int i = 2; i <= n; i++) {
    if (lp[i] != i || bad[i]) continue;
    res += pref_lp[n / i];
    for (int j = i; j <= n; j += i)
      if (lp[j] <= n / i) res--;
  }
  for (int i = 2; i <= n; i++) {
    int a = lp[i], b = i / a;
    if (b != 1 && lp[b] == b && a != b) res--;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  precomp();
  long long cnt_all = (n - cnt_bad) * 1ll * (n - cnt_bad - 1) / 2ll;
  long long cnt_one = get_dist_one();
  long long cnt_two = get_dist_two();
  long long cnt_three = cnt_all - cnt_one - cnt_two;
  printf("%lld\n",
         cnt_one + cnt_two + cnt_two + cnt_three + cnt_three + cnt_three);
  return 0;
}
