#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 7;
int n, m;
bool Prime[N];
int p[N >> 3], phi[N], mns[N], pin[N], tot, tnt[N];
void xxs(int x) {
  phi[1] = 1;
  for (int i = (2); i <= (x); ++i) {
    if (!Prime[i]) p[++tot] = i, phi[i] = i - 1, pin[i] = 1;
    for (int j = 1; j <= tot && p[j] * i <= x; j++) {
      Prime[p[j] * i] = 1, mns[p[j] * i] = p[j], pin[p[j] * i] = pin[i] + 1,
                   tnt[p[j]]++;
      if (i % p[j] == 0) {
        phi[p[j] * i] = phi[i] * p[j], pin[p[j] * i]--;
        break;
      }
      phi[p[j] * i] = phi[i] * (p[j] - 1);
    }
  }
}
long long ns;
int main() {
  cin >> n, xxs(n);
  int n2 = 0;
  for (int i = (1); i <= (tot); ++i)
    if (p[i] * 2 <= n) n2 = i;
  ns += (long long)3 * n2 * (n2 - 1) / 2;
  for (int i = (1); i <= (tot); ++i)
    for (int j = (i + 1); j <= (tot); ++j) {
      if ((long long)p[i] * p[j] > n) break;
      ns--;
    }
  int hs = 0;
  for (int i = (2); i <= (n); ++i)
    if (Prime[i]) ++hs, ns -= i - phi[i] - pin[i] - 1;
  ns += (long long)hs * (hs - 1);
  ns += (long long)n2 * hs * 3;
  for (int i = (1); i <= (tot); ++i)
    for (int j = (1); j <= (tot); ++j) {
      if ((long long)p[i] * p[j] > n) break;
      ns -= tnt[p[j]];
    }
  for (int i = (1); i <= (tot); ++i) {
    for (int j = p[i] * 2; j <= n; j += p[i]) {
      if ((long long)mns[j] * p[i] <= n)
        ns--;
      else
        ns++;
    }
  }
  cout << ns << "\n";
  return 0;
}
