#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, k, p[N], tot, phi[N];
bool np[N];
int main() {
  cin >> n >> k;
  if (k == 1) {
    puts("3");
    return 0;
  }
  phi[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!np[i]) {
      p[++tot] = i;
      phi[i] = i - 1;
    }
    for (int j = 1; j <= tot && i * p[j] <= n; ++j) {
      int x = i * p[j];
      np[x] = true;
      if (i % p[j])
        phi[x] = phi[i] * (p[j] - 1);
      else {
        phi[x] = phi[i] * p[j];
        break;
      }
    }
  }
  nth_element(phi + 1, phi + k + 3, phi + n + 1);
  long long ans = 0;
  for (int i = 1; i <= k + 2; ++i) ans += phi[i];
  cout << ans;
  return 0;
}
