#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
long long ph[N], ans;
int p[N], n, cnt, k;
bool isp[N];
inline void phi() {
  register long long x;
  ph[1] = 1;
  for (register int i = 2; i < N; ++i) {
    if (!isp[i]) p[++cnt] = i, ph[i] = i - 1;
    for (register int j = 1; (x = 1ll * p[j] * i) < N && j <= cnt; ++j) {
      isp[x] = true;
      if (i % p[j])
        ph[x] = 1ll * ph[i] * (p[j] - 1);
      else {
        ph[x] = 1ll * ph[i] * p[j];
        break;
      }
    }
  }
}
int main() {
  phi(), scanf("%d%d", &n, &k);
  if (k == 1) {
    putchar('3');
    return 0;
  }
  sort(ph + 1, ph + 1 + n);
  for (register int i = k + 2; i >= 1; --i) ans += ph[i];
  printf("%lld", ans);
  return 0;
}
