#include <bits/stdc++.h>
using namespace std;
long long x, y, n, m, k, i, j, q, w;
long long cur[1488228 * 2], pres[1488228], a[1488228], t[1488228 * 2];
vector<long long> f;
long long phis[1005000];
long long pr[1005000];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  for (int i = 2; i <= 1000000; i++) {
    pr[i] = 1;
  }
  for (int i = 1; i <= 1000000; i++) {
    phis[i] = i;
  }
  for (int i = 1; i <= 1000000; i++) {
    for (int j = i + i; j <= 1000000; j += i) {
      phis[j] -= phis[i];
    }
  }
  cin >> n >> k;
  long long ans = (long long)1e+18;
  for (int j = 0; j < 2; j++) {
    f.clear();
    for (int i = 3; i <= n; i++) {
      if (j == 0 || i % 2 == 1) {
        f.push_back(phis[i]);
      }
    }
    if (k > f.size()) {
      continue;
    }
    long long sum = 1 - j;
    sort(f.begin(), f.end());
    for (int i = 0; i < k; i++) {
      sum += f[i];
    }
    ans = min(ans, sum);
  }
  cout << ans + 1 << endl;
  return 0;
}
