#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N, K;
int sp[1000013];
int phi[1000013];
vector<int> primes;
vector<int> wtf;
long long ans;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> K;
  if (K == 1) {
    cout << "3\n";
    return 0;
  }
  K++;
  for (auto i = (2); i < (N + 2); i++) {
    if (sp[i] == 0) {
      sp[i] = i;
      primes.push_back(i);
    }
    for (int p : primes) {
      if (p * i > N || p > sp[i]) break;
      sp[p * i] = p;
    }
  }
  for (auto i = (2); i < (N + 1); i++) {
    set<int> s;
    int x = i;
    while (x > 1) {
      s.insert(sp[x]);
      x /= sp[x];
    }
    phi[i] = i;
    for (int p : s) {
      phi[i] /= p;
      phi[i] *= (p - 1);
    }
    wtf.push_back(phi[i]);
  }
  sort((wtf).begin(), (wtf).end());
  ans++;
  for (auto i = (0); i < (K); i++) ans += wtf[i];
  cout << ans << '\n';
  return 0;
}
