#include <bits/stdc++.h>
using namespace std;
int n, k;
int p[1000005], phi[1000005], cnt;
int vis[1000005];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
    if (ch == -1) return 0;
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
long long sum = 2;
vector<int> ans;
int main() {
  n = read(), k = read(), phi[1] = 1, vis[1] = 1;
  for (int i = 2; i < 1000005; i++) {
    if (!vis[i]) p[cnt++] = i, phi[i] = i - 1;
    for (int j = 0; j < cnt && p[j] * i < 1000005; j++) {
      vis[p[j] * i] = 1;
      if (i % p[j] == 0) {
        phi[i * p[j]] = phi[i] * p[j];
        break;
      }
      phi[i * p[j]] = phi[i] * (p[j] - 1);
    }
  }
  if (k == 1)
    puts("3");
  else {
    for (int i = 3; i <= n; i++) ans.push_back(phi[i]);
    sort(ans.begin(), ans.end());
    for (int i = 0; i < k; i++) sum += ans[i];
    cout << sum << endl;
  }
  return 0;
}
