#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 23;
int phi[maxn];
int prime[maxn];
int cnt, n, k;
bool mark[maxn];
void getphi() {
  phi[1] = 1;
  cnt = 0;
  for (int i = 2; i < maxn; i++) {
    if (!mark[i]) {
      prime[cnt++] = i;
      phi[i] = i - 1;
    }
    for (int j = 0; j < cnt; j++) {
      if (1LL * i * prime[j] >= maxn) break;
      mark[i * prime[j]] = 1;
      if (i % prime[j] == 0) {
        phi[i * prime[j]] = phi[i] * prime[j];
        break;
      } else
        phi[i * prime[j]] = phi[i] * (prime[j] - 1);
    }
  }
}
int main() {
  getphi();
  cin >> n >> k;
  sort(phi + 3, phi + n + 1);
  long long ans = 0;
  for (int i = 0; i < k; i++) ans += phi[i + 3];
  if (k == 1) ans--;
  printf("%lld", ans + 2);
}
