#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
int n, k, tot;
long long ans;
int p[1000010], phi[1000010];
bool tag[1000010];
void init() {
  phi[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!tag[i]) phi[p[++tot] = i] = i - 1;
    for (int j = 1; j <= tot; ++j) {
      int k = i * p[j];
      if (k > n) break;
      tag[k] = true;
      if (i % p[j])
        phi[k] = phi[i] * (p[j] - 1);
      else {
        phi[k] = phi[i] * p[j];
        break;
      }
    }
  }
}
int main() {
  read(n), read(k), init(), tot = 0;
  if (k == 1) {
    puts("3");
    return 0;
  }
  for (int i = 3; i <= n; ++i) p[++tot] = phi[i];
  sort(p + 1, p + tot + 1);
  for (int i = 1; i <= k; ++i) ans += p[i];
  printf("%lld", ans + 2);
  return 0;
}
