#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000010;
int phi[maxn];
int f[maxn];
bool vis[maxn];
int prime[maxn];
int cur = 0;
int cnt[maxn];
int sum[maxn];
int n;
long long num1, num2, num3, num4;
long long ans;
void Linear_shaker() {
  phi[1] = f[1] = 1;
  for (int i = 2; i < maxn; i++) {
    if (!vis[i]) prime[++cur] = i, phi[i] = i - 1, f[i] = i;
    for (int j = 1; j <= cur && i * prime[j] < maxn; j++) {
      int k = i * prime[j];
      f[k] = prime[j];
      vis[k] = true;
      if (i % prime[j])
        phi[k] = phi[i] * phi[prime[j]];
      else {
        phi[k] = phi[i] * prime[j];
        break;
      }
    }
  }
}
int main() {
  Linear_shaker();
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) cnt[f[i]]++;
  for (int i = 2; i <= n; i++) sum[i] = sum[i - 1] + cnt[i];
  num1 = 0;
  for (int i = 2; i <= n; i++)
    num1 += ((long long)cnt[i] * (long long)sum[n / i]);
  int sn = (int)floor(sqrt((double)n) + 1e-4);
  for (int i = 2; i <= sn; i++) num1 -= (long long)cnt[i];
  num2 = 0;
  for (int i = 2; i <= n; i++) num2 += (long long)(i - phi[i] - 1);
  num2 <<= 1;
  num1 -= num2;
  swap(num1, num2);
  num3 = 0;
  for (int i = 2; i <= n; i++) num3 += (long long)(phi[i] - 1);
  num3 <<= 1;
  num3 -= num2;
  num4 = 0;
  for (int i = 1; i <= n; i++)
    if (2 * i > n) num4 += ((long long)cnt[i] * (long long)(n - 2));
  num4 <<= 1;
  int temp = 0;
  for (int i = 1; i <= n; i++)
    if (2 * i > n && !vis[i]) temp++;
  num4 -= ((long long)temp * (long long)(temp - 1));
  num3 -= num4;
  num1 >>= 1;
  num2 >>= 1;
  num3 >>= 1;
  ans = num1 + 2LL * num2 + 3LL * num3;
  printf("%I64d\n", ans);
  return 0;
}
