#include <bits/stdc++.h>
using namespace std;
int n, k, p[1000001];
long long ans;
int main() {
  scanf("%d%d", &n, &k);
  if (k == 1) {
    printf("3");
    return 0;
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 2; i <= n; i++)
    if (p[i] == i)
      for (int j = i; j <= n; j += i) p[j] -= p[j] / i;
  sort(p + 1, p + 1 + n);
  for (int i = 1; i <= k + 2; i++) ans += p[i];
  printf("%I64d", ans);
  return 0;
}
