#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const int N = 1000001;
int _max(int x, int y) { return x > y ? x : y; }
int _min(int x, int y) { return x < y ? x : y; }
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
void put(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) put(x / 10);
  putchar(x % 10 + '0');
}
bool v[N];
int phi[N];
int plen, p[N];
void get_p() {
  phi[1] = 1;
  for (int i = 2; i < N; i++) {
    if (!v[i]) p[++plen] = i, phi[i] = i - 1;
    for (int j = 1; j <= plen && i * p[j] < N; j++) {
      v[i * p[j]] = 1;
      if (i % p[j] == 0) {
        phi[i * p[j]] = phi[i] * p[j];
        break;
      } else
        phi[i * p[j]] = phi[i] * (p[j] - 1);
    }
  }
}
int main() {
  get_p();
  int n = read(), k = read();
  long long ans = 0;
  if (k == 1) {
    puts("3");
    return 0;
  }
  sort(phi + 1, phi + n + 1);
  for (int i = 1; i <= k + 2; i++) ans += phi[i];
  put(ans), puts("");
  return 0;
}
