#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e6 + 123, inf = 1e9, mod = 1e9 + 7;
const long long INF = 1e18;
int n, k, ld[N], first[N];
long long ans;
int main() {
  cin >> n >> k;
  if (k == 1) {
    cout << 3;
    return 0;
  }
  for (int i = 2; i <= n; i++)
    if (ld[i] == 0)
      for (int j = i; j <= n; j += i) ld[j] = i;
  k += 2;
  first[1] = 1;
  for (int i = 2; i <= n; i++) {
    int x = i, y = 1, p = ld[i];
    while (x % p == 0) x /= p, y *= p;
    first[i] = y / p * (p - 1) * first[x];
  }
  sort(first + 1, first + 1 + n);
  for (int i = 1; i <= k; i++) ans += first[i];
  cout << ans;
  return 0;
}
