#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x(0), f(1);
  register char c(getchar());
  while (c > '9' || c < '0') f = c == '-' ? -1 : 1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return f * x;
}
const int N = 2100000;
int vis[N], prim[N], phi[N], cnt;
void pre(int n) {
  register int i, j;
  phi[1] = 1;
  for (i = 2; i <= n; i++) {
    if (!vis[i]) prim[++cnt] = i, phi[i] = i - 1;
    for (j = 1; j <= cnt && i * prim[j] <= n; j++) {
      vis[i * prim[j]] = 1;
      if (i % prim[j] == 0) {
        phi[i * prim[j]] = phi[i] * prim[j];
        break;
      } else {
        phi[i * prim[j]] = phi[i] * (prim[j] - 1);
      }
    }
  }
}
int n, K;
long long ans;
int main() {
  register int i;
  n = read();
  K = read();
  if (K == 1) {
    cout << 3;
    return 0;
  }
  pre(n);
  sort(phi + 1, phi + 1 + n);
  for (i = 1; i <= K + 2; i++) ans += phi[i];
  cout << ans;
  return 0;
}
