#include <bits/stdc++.h>
using namespace std;
const int INFi = 1e9 + 5;
const int maxN = 1e6 + 5;
const int md = 998244353;
const long long INF = 2e18;
double getTime() { return clock() / (double)CLOCKS_PER_SEC; }
int phi[maxN];
int mp[maxN];
vector<int> primes;
void init() {
  for (int i = 2; i < maxN; ++i) {
    if (!mp[i]) {
      mp[i] = i;
      primes.push_back(i);
      phi[i] = i - 1;
    }
    for (auto &p : primes) {
      if (1ll * p * i >= maxN || p > mp[i]) break;
      mp[p * i] = p;
      if (p == mp[i]) {
        phi[p * i] = phi[i] * p;
      } else {
        phi[p * i] = phi[i] * (p - 1);
      }
    }
  }
}
void solve() {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << "3\n";
    return;
  }
  init();
  vector<int> ord;
  k++;
  for (int i = 2; i <= n; ++i) ord.push_back(phi[i]);
  sort((ord).begin(), (ord).end());
  ord.resize(k);
  cout << accumulate((ord).begin(), (ord).end(), 0ll) + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tests = 1;
  for (int _ = 0; _ < (tests); ++_) {
    solve();
  }
  return 0;
}
