#include <bits/stdc++.h>
const int kMaxN = 1e7 + 5;
int N;
int phi[kMaxN];
long long prime[kMaxN], primeList[kMaxN], count[kMaxN];
int k = 0;
void ComputePhi() {
  for (int i = 1; i <= N; i++) {
    phi[i] = i;
  }
  for (int i = 2; i <= N; i++) {
    if (phi[i] == i) {
      for (int j = i; j <= N; j += i) {
        phi[j] = phi[j] / i * (i - 1);
      }
    }
  }
}
void ComputePrimes() {
  for (int i = 2; i <= N; i++) {
    if (prime[i] != 0) {
      count[prime[i]]++;
      continue;
    }
    for (int j = i; j <= N; j += i) {
      if (!prime[j]) {
        prime[j] = i;
      }
    }
    count[prime[i]]++;
  }
  for (int i = 2; i <= N; i++) {
    while (count[i] > 0) {
      primeList[++k] = i;
      count[i]--;
    }
  }
}
int main() {
  scanf("%d", &N);
  ComputePhi();
  ComputePrimes();
  long long sol = 0;
  for (int i = 2; i <= N; i++) {
    sol += i - 1 - phi[i];
  }
  sol *= -1;
  int cursor = k;
  for (int i = 1; i <= k; i++) {
    while (cursor >= i && primeList[i] * primeList[cursor] > N) {
      cursor--;
    }
    if (cursor >= i) {
      sol += 2LL * (cursor - i);
    }
  }
  cursor = k;
  for (int i = 1; i <= k; i++) {
    while (cursor > 0 && primeList[i] * primeList[cursor] > N) {
      cursor--;
    }
    cursor++;
    if (2 * primeList[i] <= N && cursor < i &&
        primeList[i] * primeList[cursor] > N) {
      sol += 3LL * (i - cursor);
    }
  }
  printf("%lld\n", sol);
  return 0;
}
