#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << "3\n";
    return 0;
  }
  vector<int> phi(n + 1);
  for (int i = 0; i <= n; i++) phi[i] = i;
  for (int p = 2; p <= n; p++) {
    if (phi[p] == p) {
      for (int i = p; i <= n; i += p) {
        phi[i] -= phi[i] / p;
      }
    }
  }
  sort(phi.begin(), phi.end());
  long long ans = 0;
  for (int i = 0; i < k + 3; i++) {
    ans += phi[i];
  }
  cout << ans << "\n";
  return 0;
}
