#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class C>
void mini(C &a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C &a4, C b4) {
  a4 = max(a4, b4);
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const long long MAX = 1e6 + 5;
long long np[MAX];
long long koszt[MAX];
long long n, k;
long long ilepom[MAX], ile[MAX];
const long long inf = 1e18;
long long licz() {
  set<pair<long long, long long> > secik;
  for (long long i = 3; i <= n; i++) {
    if (ile[i] == 0) secik.insert({koszt[i], i});
  }
  long long res = 0;
  for (long long _ = (0); _ <= ((long long)(k)-1); _++) {
    if (secik.empty()) return inf;
    pair<long long, long long> pom = *secik.begin();
    (pom);
    res += pom.first;
    secik.erase(secik.begin());
    for (long long j = 2; j * pom.second <= n; j++) {
      long long i = j * pom.second;
      koszt[i] -= pom.first;
      ile[i]--;
      if (ile[i] == 0) secik.insert({koszt[i], i});
    }
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  if (0) cout << fixed << setprecision(6);
  cin >> n >> k;
  for (long long i = 3; i <= n; i++) {
    for (long long j = 2; i * j <= n; j++) {
      ilepom[i * j]++;
    }
  }
  for (long long i = (0); i <= ((long long)(n + 1) - 1); i++) {
    koszt[i] = (i % 2 ? i - 1 : inf);
    ile[i] = (i % 2 ? ilepom[i] : inf);
  }
  long long res1 = licz() + 1;
  for (long long i = (0); i <= ((long long)(n + 1) - 1); i++) {
    koszt[i] = i - (i % 2 ? 1 : 2);
    ile[i] = ilepom[i];
  }
  long long res2 = licz() + 2;
  (res1, res2);
  cout << min(res1, res2) << "\n";
}
