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