#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 2;
long long phi[N];
signed main() {
  long long n, k, i, j, l, ans = 0;
  cin >> n >> k;
  for (i = 2; i <= n; i++) {
    phi[i] = i;
  }
  for (i = 2; i <= n; i++) {
    if (phi[i] == i) {
      for (j = i; j <= n; j += i) {
        phi[j] /= i;
        phi[j] *= (i - 1);
      }
    }
  }
  sort(phi + 3, phi + n + 1);
  for (i = 3; i < 3 + k; i++) {
    ans += phi[i];
  }
  if (k >= 2) {
    ans++;
  }
  cout << ans + 1;
}
