#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
template <typename T>
void read(T &x) {
  char c = getchar();
  int f = 0;
  while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
  for (x = 0; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + c - '0';
  if (f) x = -x;
}
int n, k;
int pri[N], phi[N];
void init() {
  for (int i = 1; i <= n; ++i) phi[i] = i;
  for (int i = 2; i <= n; ++i) {
    if (!pri[i]) {
      for (int j = i; j <= n; j += i) {
        phi[j] = phi[j] / i * (i - 1);
        pri[j] = 1;
      }
    }
  }
}
bool cmp(int x, int y) {
  if (phi[x] == phi[y]) {
    return (x % 2) > (y % 2);
  }
  return phi[x] < phi[y];
}
int main() {
  read(n);
  read(k);
  init();
  static int a[N];
  for (int i = 3; i <= n; ++i) a[i] = i;
  sort(a + 3, a + n + 1, cmp);
  long long ans = 1, tag = 0;
  for (int i = 3; i < k + 3; ++i) {
    ans += phi[a[i]];
    if (!tag && a[i] % 2 == 0) ++ans, tag = 1;
  }
  cout << ans << endl;
  return 0;
}
