#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return x * f;
}
const int N = 1e7 + 10, NP = 1e6 + 10;
bool is[N];
int p[NP], phi[N], lp;
void getphi(int n) {
  phi[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!is[i]) p[++lp] = i, phi[i] = i - 1;
    for (int j = 1; j <= lp && p[j] * i <= n; ++j) {
      int x = p[j] * i;
      is[x] = 1;
      if (i % p[j])
        phi[x] = phi[i] * (p[j] - 1);
      else {
        phi[x] = phi[i] * p[j];
        break;
      }
    }
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  if (k == 1) {
    puts("3");
    return 0;
  }
  getphi(n);
  nth_element(phi + 1, phi + k + 3, phi + n + 1);
  long long ans = 0;
  for (int i = 1; i <= k + 2; ++i) ans += phi[i];
  printf("%lld\n", ans);
  return 0;
}
