#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;
const int N = 1e7 + 2;
vector<int> ps;
int pdiv[N];
int pcnt[N];
int divcnt[N];
int totp[N];
int phi[N], mu[N];
void pre(int n) {
  iota(pdiv, pdiv + n + 1, 0);
  mu[1] = phi[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (pdiv[i] == i) {
      ps.push_back(i);
      mu[i] = -1;
      phi[i] = i - 1;
      totp[i]++;
      for (int j = i; j <= n; j += i) {
        divcnt[j]++;
      }
    }
    for (int ip, j = 0; j < ps.size() && (ip = i * ps[j]) <= n; j++) {
      pdiv[ip] = ps[j];
      if (i % ps[j] == 0) {
        mu[ip] = 0;
        phi[ip] = phi[i] * ps[j];
        break;
      } else {
        mu[ip] = -mu[i];
        phi[ip] = phi[i] * phi[ps[j]];
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    pcnt[pdiv[i]]++;
  }
  for (int i = 2; i <= n; i++) {
    pcnt[i] += pcnt[i - 1];
  }
  for (int i = 2; i <= n; i++) {
    totp[i] += totp[i - 1];
  }
}
ll cnt[4];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  pre(n);
  ll bad = 1;
  for (int i = n / 2 + 1; i <= n; i++) {
    bad += (i > 1 && pdiv[i] == i);
  }
  cnt[0] = bad * (n - bad) + bad * (bad - 1) / 2;
  ll coprime = 0;
  for (int d = 1; d <= n; d++) {
    coprime += (ll)mu[d] * (n / d) * (n / d);
  }
  coprime -= 1;
  coprime /= 2;
  cnt[1] = n * (n - 1) / 2 - coprime;
  int pnum = 0;
  for (int i = 1; i <= n; i++) {
    if (pdiv[i] == i) {
      pnum++;
      continue;
    }
    cnt[2] += phi[i] - (pnum - divcnt[i]);
  }
  for (int i = 2; i <= n; i++) {
    if (i != pdiv[i]) continue;
    cnt[2] += pcnt[n / i];
    for (int j = i; j <= n; j += i) {
      cnt[2] -= (pdiv[j] <= n / i);
    }
    cnt[2] -= totp[min((ll)i - 1, n / i)];
  }
  cnt[3] = n * (n - 1) / 2 - cnt[0] - cnt[1] - cnt[2];
  ll ans = 0;
  for (int i = 0; i < 4; i++) {
    ans += i * cnt[i];
  }
  cout << ans << nl;
}
