#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int flag[10101010], phi[10101010], cnt[10101010];
int sum[10101010 / 10], prime[10101010 / 10], np;
void pre(int n) {
  for (int i = 1; i <= n; i++) phi[i] = i;
  for (int i = 2; i <= n; i += 2) phi[i] /= 2;
  for (int i = 3; i <= n; i += 2)
    if (phi[i] == i) {
      for (int j = i; j <= n; j += i) phi[j] -= phi[j] / i;
    }
  flag[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (flag[i]) {
      cnt[flag[i]]++;
      continue;
    }
    flag[i] = i;
    cnt[flag[i]]++;
    prime[np++] = i;
    if ((long long)i * i > n) continue;
    for (int j = i * i; j <= n; j += i)
      if (!flag[j]) flag[j] = i;
  }
  for (int s = 0, i = np - 1; i >= 0; i--) {
    if (prime[i] * 2 > n) continue;
    s += cnt[prime[i]];
    sum[i] = s;
  }
}
long long calc1(int n) {
  long long ans = 0;
  for (int i = 2; i <= n; i++) ans += i - phi[i] - 1;
  return ans;
}
long long calc3(int n) {
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (prime[i] * 2 > n) break;
    int u = upper_bound(prime, prime + np, n / prime[i]) - prime;
    smax(u, i + 1);
    ans += 1LL * cnt[prime[i]] * sum[u];
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  if (n == 1) return puts("0");
  pre(n);
  int tot = 1;
  for (int i = n / 2 + 1; i <= n; i++)
    if (flag[i] == i) tot++;
  tot = n - tot;
  long long s = 1LL * tot * (tot - 1) / 2;
  long long s1 = calc1(n);
  long long s3 = calc3(n);
  long long s2 = s - s1 - s3;
  println(s1 + s2 * 2 + s3 * 3);
  return 0;
}
