#include <bits/stdc++.h>
using namespace std;
void Main();
int main() {
  ios::sync_with_stdio(0);
  while (~cin.peek()) Main(), cin.get();
  return 0;
}
vector<int> getphi(int n) {
  vector<int> phi(n), prime, mark(n);
  phi[1] = 1;
  for (int i = 2; i < n; i++) {
    if (!mark[i]) {
      prime.push_back(i);
      phi[i] = i - 1;
    }
    for (int j = 0; j < prime.size(); j++) {
      int num = prime[j] * i;
      if (num >= n) break;
      mark[num] = 1;
      if (i % prime[j] == 0) {
        phi[num] = phi[i] * prime[j];
        break;
      } else {
        phi[num] = phi[i] * (prime[j] - 1);
      }
    }
  }
  return phi;
}
void Main() {
  int n, k;
  cin >> n >> k;
  long long ans = 1e18;
  for (int take2 = 0; take2 <= 1; take2++) {
    auto phi = getphi(n + 1);
    if (!take2) {
      for (int i = 4; i <= n; i += 2) {
        phi[i] = 1e9;
      }
    }
    sort(phi.begin() + 3, phi.end());
    long long tmp = take2;
    for (int i = 3; i <= k + 2; i++) {
      tmp += phi[i];
    }
    ans = min(ans, tmp);
  }
  cout << ans + 1 << endl;
}
