#include <bits/stdc++.h>
using namespace std;
int N = 10000000;
int n, tot;
int pr[2000005], p[10000605], mu[10000605], phi[10000605], cnt[10000605];
void init() {
  mu[1] = 1;
  p[1] = 1;
  phi[1] = 1;
  for (int i = 2; i <= N; i++) {
    if (!p[i]) {
      p[i] = i;
      pr[++tot] = i;
      mu[i] = -1;
      phi[i] = i - 1;
    }
    for (int j = 1; j <= tot && pr[j] * i <= N; j++) {
      p[i * pr[j]] = pr[j];
      if (p[i] == pr[j]) {
        phi[i * pr[j]] = phi[i] * pr[j];
        break;
      } else {
        mu[i * pr[j]] = -mu[i];
        phi[i * pr[j]] = phi[i] * (pr[j] - 1);
      }
    }
  }
}
long long calc1() {
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    ans += i - phi[i] - 1;
  }
  return ans;
}
long long calc0() {
  long long ans = 0;
  long long u = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 1 || (2 * i > n && p[i] == i)) {
      ans += i - 1;
      u++;
    } else {
      ans += u;
    }
  }
  return ans;
}
long long calc2() {
  long long sm = 0;
  for (int d = 1; d <= n; d++) {
    if (mu[d]) {
      long long ans = 0;
      if (n / d >= 100000) {
        int mv = 0;
        for (int i = d; i <= n; i += d) {
          mv = max(mv, p[i]);
        }
        for (int i = 1; i <= mv; i++) {
          cnt[i] = 0;
        }
        for (int i = d; i <= n; i += d) {
          cnt[p[i]]++;
        }
        for (int i = 1; i <= mv; i++) {
          cnt[i] += cnt[i - 1];
        }
        for (int i = 1; i <= mv; i++) {
          if (cnt[i] != cnt[i - 1]) {
            ans += (long long)(cnt[i] - cnt[i - 1]) * cnt[min(mv, n / i)];
          }
        }
      } else {
        tot = 0;
        for (int i = d; i <= n; i += d) {
          cnt[tot++] = p[i];
        }
        sort(cnt, cnt + tot);
        int r = tot - 1;
        for (int i = 0; i < tot; i++) {
          while (r >= 0 && (long long)cnt[i] * cnt[r] > n) r--;
          ans += r + 1;
        }
      }
      sm += mu[d] * ans;
    }
  }
  return (sm + 1LL) / 2LL - n;
}
int main(void) {
  init();
  scanf("%d", &n);
  long long sum = (long long)n * (n - 1) / 2LL;
  long long t1 = calc1();
  long long t0 = calc0();
  long long t2 = calc2();
  long long t3 = sum - t0 - t1 - t2;
  printf("%lld\n", t1 + t2 * 2LL + t3 * 3LL);
  return 0;
}
