#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const int MOD = 1000000007;
const int nmax = 1012345;
int n, k, p[nmax], cnt[nmax];
long long res;
void prime(int n) {
  for (int i = 2; i <= n; ++i)
    if (p[i] == 0)
      for (int j = i; j <= n; j += i) {
        cnt[j] = cnt[j] / i * (i - 1);
        p[j] = 1;
      }
}
int main() {
  scanf("%d%d", &n, &k);
  if (k == 1) return 0 * puts("3");
  for (int i = 2; i <= n; ++i) cnt[i] = i;
  prime(n);
  sort(cnt + 3, cnt + n + 1);
  k += 3;
  for (int i = 3; i < k; ++i) res = res + cnt[i];
  printf("%I64d\n", res + 2);
  return 0;
}
