#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[1000010], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <typename T>
inline void read(T& x) {
  char ch = getchar();
  T a = 0, b = 1;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') ch = getchar(), b = -1;
  while (ch >= '0' && ch <= '9') a = a * 10 + ch - '0', ch = getchar();
  x = a * b;
}
template <typename T>
inline void Swap(T& x, T& y) {
  x = x ^ y;
  y = x ^ y;
  x = x ^ y;
}
template <typename T>
inline void chkmin(T& x, T y) {
  x = (y < x ? y : x);
}
template <typename T>
inline void chkmax(T& x, T y) {
  x = (y > x ? y : x);
}
template <typename T>
inline T Min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
inline T Max(T x, T y) {
  return x > y ? x : y;
}
const int maxn = 1e6;
int n, k, tot, prime[maxn + 10], not_prime[maxn + 10], phi[maxn + 10];
void init() {
  phi[1] = 1;
  for (int i = 2; i <= maxn; ++i) {
    if (!not_prime[i]) {
      prime[++tot] = i;
      phi[i] = i - 1;
    }
    for (int j = 1; j <= tot && 1ll * i * prime[j] <= maxn; ++j) {
      not_prime[i * prime[j]] = 1;
      if (i % prime[j] == 0) {
        phi[i * prime[j]] = phi[i] * prime[j];
        break;
      }
      phi[i * prime[j]] = phi[i] * (prime[j] - 1);
    }
  }
}
int main() {
  init();
  read(n);
  read(k);
  if (k <= 1) {
    printf("%d\n", 3);
    return 0;
  }
  if (k <= 2) {
    printf("%d\n", 6);
    return 0;
  }
  long long ans = 6;
  sort(phi + 5, phi + 1 + n);
  for (int i = 5; i <= 5 + k - 2 - 1; ++i) ans += phi[i];
  printf("%lld\n", ans);
  return 0;
}
