#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int c, int ans = 1) {
  for (; b; b >>= 1, a = (long long)a * a % c)
    if (b & 1) ans = (long long)ans * a % c;
  return ans;
}
int phi[1000100];
int main() {
  int n, k;
  cin >> n >> k;
  if (k == 1) return puts("3");
  for (int i = 1; i <= n; i++) phi[i] = i;
  for (int i = 2; i <= n; i += 2) phi[i] >>= 1;
  for (int i = 3; i <= n; i += 2)
    if (phi[i] == i)
      for (int j = i; j <= n; j += i) phi[j] -= phi[j] / i;
  sort(phi + 1, phi + n + 1);
  long long ans = 0;
  for (int i = 1; i <= k + 2; i++) ans += phi[i];
  cout << ans << endl;
  return 0;
}
