#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 1000007, MOD = 1e9 + 7;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long P = 19260817;
int n, k;
int phi[maxn], prime[maxn], vis[maxn];
int tot = 0;
int main() {
  scanf("%d%d", &n, &k);
  phi[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) prime[++tot] = i, phi[i] = i - 1;
    for (int j = 1; j <= tot; j++) {
      if (i * prime[j] > n) break;
      vis[i * prime[j]] = true;
      if (i % prime[j] == 0) {
        phi[i * prime[j]] = phi[i] * prime[j];
        break;
      }
      phi[i * prime[j]] = phi[i] * (prime[j] - 1);
    }
  }
  sort(phi + 1, phi + n + 1);
  long long ans = 0;
  for (int i = 1; i <= k + 2; i++) ans += (long long)phi[i];
  printf("%lld", k == 1 ? 3ll : ans);
  return 0;
}
