#include <bits/stdc++.h>
const int MAXN = 10000000 + 10;
const int INF = 0x7fffffff;
const long long MOD = 1000000007;
using namespace std;
int miu[MAXN], sum[MAXN];
int vis[MAXN], prime[MAXN];
int fw[MAXN], mini[MAXN];
void prepare() {
  miu[1] = 1;
  memset(vis, 0, sizeof(vis));
  memset(mini, 0, sizeof(mini));
  memset(fw, 0, sizeof(fw));
  prime[0] = 0;
  for (int i = 2; i <= 10000000; i++) {
    if (vis[i] == 0) {
      prime[++prime[0]] = i;
      miu[i] = -1;
      mini[i] = i;
    }
    for (int j = 1; j <= prime[0]; j++) {
      if (i * prime[j] > 10000000) break;
      if (i % prime[j] != 0) miu[i * prime[j]] = miu[i] * miu[prime[j]];
      vis[i * prime[j]] = 1;
      if (mini[i * prime[j]] == 0)
        mini[i * prime[j]] = prime[j];
      else
        mini[i * prime[j]] = min(mini[i * prime[j]], prime[j]);
      if (i % prime[j] == 0) break;
    }
  }
  sum[0] = 0;
  for (int i = 1; i <= 10000000; i++) sum[i] = sum[i - 1] + miu[i];
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
long long get(int a, int b) {
  long long Ans = 0ll;
  int last = 1, cnt = 0;
  for (int i = 1; i <= min(a, b); i = last + 1) {
    last = min(a / (a / i), b / (b / i));
    Ans += (long long)((long long)(sum[last] - sum[i - 1]) *
                       (long long)(a / i) * (long long)(b / i));
    cnt++;
  }
  return Ans;
}
void Add(int v) {
  while (v <= 10000000) {
    fw[v]++;
    v += v & -v;
  }
}
int Sum(int v) {
  int res = 0;
  while (v > 0) {
    res += fw[v];
    v -= v & -v;
  }
  return res;
}
int main() {
  prepare();
  long long n;
  scanf("%lld", &n);
  long long Ans = 0ll, A = 0ll, B = 0ll, C = 0ll;
  A += (((n * (n - 1ll)) / 2ll) - ((get(n, n) - 1ll) / 2));
  int count = 1;
  for (int i = 1; i <= prime[0]; i++) {
    if (prime[i] > n) break;
    if (prime[i] * 2ll > n) count++;
  }
  C = (long long)(n - count) * (long long)(n - count - 1ll) / 2ll;
  for (int i = n; i >= 2; i--) {
    int tmp = (n / mini[i]);
    B += (long long)Sum(tmp);
    Add(mini[i]);
  }
  printf("%lld\n", A + 2ll * (long long)(B - A) + 3ll * (long long)(C - B));
  return 0;
}
