#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int inf = 0x3f3f3f3f;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void wri(long long x) { write(x), putchar(' '); }
void writeln(long long x) { write(x), putchar('\n'); }
const int mod = 998244353;
const int maxn = 1 << 19 | 233;
int n, k, f[1 << 21];
int main() {
  n = read(), k = read();
  if (k == 1) {
    writeln(3);
    return 0;
  }
  for (register int i = (1); i <= int(n); ++i) f[i] = i;
  for (register int i = (1); i <= int(n); ++i)
    for (int j = i + i; j <= n; j += i) f[j] -= f[i];
  sort(f + 1, f + 1 + n);
  long long ans = 0;
  for (register int i = (1); i <= int(k + 2); ++i) ans += f[i];
  writeln(ans);
  return 0;
}
