#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int NN = 10000005;
int lp[NN], pref[NN], isp[NN], phi[NN];
void pre(int N) {
  N++;
  for (int i = 2; i < N; i++) {
    if (isp[i] == 0) {
      lp[i] = i;
      pref[i]++;
      for (int j = 2 * i; j < N; j += i) {
        if (isp[j] == 0) {
          isp[j] = 1;
          lp[j] = i;
          pref[i]++;
        }
      }
    }
  }
  for (int i = 1; i < N; i++) pref[i] += pref[i - 1];
  phi[1] = 1;
  for (int i = 2; i < N; i++) {
    int j = i / lp[i];
    if (lp[j] == lp[i])
      phi[i] = phi[j] * lp[i];
    else
      phi[i] = (lp[i] - 1) * phi[j];
  }
}
int main() {
  long long int n;
  cin >> n;
  if (n == 1) {
    cout << "0\n";
    return 0;
  }
  pre(n);
  long long int total = n * (n - 1);
  total /= 2;
  long long int cnt = 1;
  for (int i = n / 2 + 1; i <= n; i++) {
    if (isp[i] == 0) cnt++;
  }
  long long int cnt0 = (cnt * (cnt - 1)) / 2;
  cnt0 += (cnt * (n - cnt));
  long long int cnt12 = 0;
  for (int i = 2; i <= n; i++) {
    int j = lp[i];
    int k = n / j;
    cnt12 += (pref[k]);
    if (k >= j) {
      cnt12--;
    }
  }
  cnt12 /= 2;
  long long int cnt1 = 0;
  for (int i = 2; i <= n; i++) {
    cnt1 += (i - 1 - phi[i]);
  }
  __f("total, cnt0, cnt12, cnt1", total, cnt0, cnt12, cnt1);
  long long int cnt2 = cnt12 - cnt1;
  long long int cnt3 = total - cnt0 - cnt12;
  long long int fans = cnt1;
  fans += (2 * cnt2);
  fans += (3 * cnt3);
  cout << fans << "\n";
  return 0;
}
