#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long phi[1000005];
void computeTotient(int n) {
  for (int i = 1; i <= n; i++) phi[i] = i;
  for (int p = 2; p <= n; p++) {
    if (phi[p] == p) {
      phi[p] = p - 1;
      for (int i = 2 * p; i <= n; i += p) {
        phi[i] = (phi[i] / p) * (p - 1);
      }
    }
  }
}
priority_queue<long long> pq;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 3;
    return 0;
  }
  computeTotient(n);
  k += 2;
  for (int i = 1; i <= n; i++) {
    pq.push(-phi[i]);
  }
  long long res = 0;
  while (k--) {
    res -= pq.top();
    pq.pop();
  }
  cout << res;
}
