#include <bits/stdc++.h>
using namespace std;
const int N = 10000010;
int to[N];
bool vis[N];
int n;
int sum[N];
long long a, b, c, d, e, f;
int cur;
int main() {
  for (int i = 1; i < N; i++) {
    to[i] = i;
  }
  for (int i = 2; i < N; i++) {
    if (to[i] != i) continue;
    for (int j = i; j < N; j += i) {
      to[j] = to[j] - (to[j] / i);
    }
  }
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    b += (i - 1 - to[i]);
    if (to[i] != i - 1) {
      sum[i] = sum[i - 1];
      continue;
    }
    if (i * 2 > n) {
      a++;
    }
    if ((long long)i * i > n) f++;
    for (int j = i; j <= n; j += i) {
      if ((long long)i * i > n && j != i) e++;
      if (vis[j]) continue;
      vis[j] = true;
      sum[i]++;
    }
    sum[i] += sum[i - 1];
  }
  a = (a + 1) * (n - a - 1) + a * (a + 1) / 2;
  c = (long long)(n - f - 1) * (n - f - 2) / 2;
  c -= (b - e);
  for (int i = 2; i * 2 <= n; i++) {
    if (to[i] != i - 1) continue;
    if ((long long)i * i <= n) continue;
    cur = n / i;
    c += sum[cur];
  }
  c -= e;
  d = (long long)n * (n - 1) / 2;
  d -= (a + b + c);
  long long ans = b + 2 * c + 3 * d;
  cout << ans << endl;
  return 0;
}
