#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e7 + 10;
int n, fac[MAX_N], pri[MAX_N], pri_n, fac_cnt[MAX_N], phi[MAX_N];
long long ans;
void init() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    if (!fac[i]) {
      phi[i] = (fac[i] = pri[++pri_n] = i) - 1;
      fac_cnt[i] = 1;
    }
    for (int j = 1; j <= pri_n && pri[j] * i <= n && pri[j] <= fac[i]; j++) {
      fac[pri[j] * i] = pri[j];
      fac_cnt[pri[j] * i] = fac_cnt[i] + (pri[j] == fac[i] ? 0 : 1);
      phi[pri[j] * i] = phi[i] * (pri[j] - (pri[j] == fac[i] ? 0 : 1));
    }
  }
}
long long get_pair_suc() {
  long long suc = 0;
  for (int i = 2; i <= n; i++)
    if (i * 2 <= n || fac[i] != i) suc++;
  return suc * (suc - 1) / 2;
}
long long get_pair_1() {
  long long res = 0;
  for (int i = 2; i <= n; i++) res += i - 1 - phi[i];
  return res;
}
long long get_pair_2() {
  static int pref_fac[MAX_N];
  int pref_pri = 0;
  long long res = 0;
  for (int i = 2; i <= n; i++) {
    if (fac[i] == i)
      pref_pri++;
    else
      res += phi[i] - (pref_pri - fac_cnt[i]) - 1;
  }
  for (int i = 2; i <= n; i++) pref_fac[fac[i]]++;
  for (int i = 2; i <= n; i++) pref_fac[i] += pref_fac[i - 1];
  for (int i = 2; i <= n; i++) {
    if (fac[i] != i) continue;
    int lim = n / fac[i];
    res += pref_fac[lim];
    for (int j = i; j <= n; j += i)
      if (fac[j] <= lim) res--;
  }
  for (int i = 2; i <= n; i++)
    if (fac_cnt[i] == 2 && fac[i / fac[i]] == i / fac[i]) res--;
  return res;
}
void solve() {
  long long pair_suc = get_pair_suc();
  long long pair_1 = get_pair_1();
  long long pair_2 = get_pair_2();
  long long pair_3 = pair_suc - pair_1 - pair_2;
  long long ans = pair_1 * 1 + pair_2 * 2 + pair_3 * 3;
  printf("%lld\n", ans);
}
int main() {
  init();
  solve();
}
