#include <bits/stdc++.h>
using namespace std;
long long etf[1000 * 1000 + 69];
int n, k;
void doetf(int n) {
  iota(etf, etf + n + 1, 0);
  for (int i = 2; i <= n; i++) {
    if (etf[i] == i) {
      etf[i] = i - 1;
      for (int j = 2 * i; j <= n; j += i) {
        etf[j] = (etf[j] * (i - 1)) / i;
      }
    }
  }
}
int main() {
  cin >> n >> k;
  if (k == 1) {
    cout << 3 << endl;
    return 0;
  }
  doetf(n);
  k += 2;
  sort(etf + 1, etf + n + 1);
  cout << accumulate(etf + 1, etf + k + 1, 0ll) << endl;
  return 0;
}
