#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int phi[MAXN];
int pfac[MAXN];
int main() {
  for (int i = 2; i < MAXN; ++i) pfac[i] = i;
  for (int i = 2; i < MAXN; ++i)
    if (pfac[i] == i)
      for (int j = i + i; j < MAXN; j += i) pfac[j] = i;
  phi[1] = 1;
  for (int i = 2; i < MAXN; ++i) {
    int ii = i, p = pfac[i], mult = p - 1;
    ii /= p;
    while (ii % p == 0) {
      ii /= p;
      mult *= p;
    }
    phi[i] = phi[ii] * mult;
  }
  int n, k;
  scanf("%d%d", &n, &k);
  if (k == 1) {
    printf("3\n");
    return 0;
  }
  sort(phi + 2, phi + n + 1);
  long long ans = 1;
  for (int i = 2; i <= k + 2; ++i) ans += phi[i];
  printf("%lld\n", ans);
}
