#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcnt(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int back[10000005], so[10000005], have[10000005], prime[10000005];
int n;
long long dem(long long x) { return x * (x - 1) / 2; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  long long all = dem(n - 1), l0 = 0, l1 = 0, l2 = 0, l3 = 0;
  memset(back, 0, sizeof(back));
  memset(so, 0, sizeof(so));
  memset(have, 0, sizeof(have));
  for (long long i = 2; i <= n; i++)
    if (back[i] == 0) {
      back[i] = i;
      for (long long j = i * i; j <= n; j += i)
        if (back[j] == 0) {
          back[j] = i;
        }
    }
  for (long long i = 2; i <= n; i++) {
    if (back[i] == i) {
      so[i] = 1;
    } else {
      int x = i / back[i];
      if (x % back[i] != 0 && so[x] != 0) {
        so[i] = so[x] + 1;
      }
    }
    if (so[i]) {
      long long A = n / i;
      if (so[i] & 1)
        l1 += dem(A);
      else
        l1 -= dem(A);
    }
    if (back[i] == i && i + i > n) l0++;
    if (back[i] != i) have[back[i]]++;
  }
  l0 = dem(l0) + l0 * (n - l0 - 1);
  for (int i = n; i >= 2; i--) have[i] += have[i + 1];
  prime[1] = 0;
  for (int i = 2; i <= n; i++) prime[i] = prime[i - 1] + (back[i] == i);
  for (int i = 2; i <= n; i++)
    if (back[i] == i && i + i <= n) {
      int u = n / i + 1;
      l3 += have[u];
      if (u < i) l3 += prime[i] - 1 - prime[u - 1];
    }
  l2 = all - l0 - l1 - l3;
  long long res = l1 + l2 * 2 + l3 * 3;
  cout << res << endl;
  return 0;
}
