#include <bits/stdc++.h>
using namespace std;
int TestMillerRabin[12] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
long long mulmod(long long a, long long b, long long p) {
  long long x = 0, y = a % p;
  while (b > 0) {
    if (b % 2 == 1) x = (x + y) % p;
    y = (1LL * y * 2) % p;
    b = b / 2;
  }
  return x % p;
}
long long fastexp(long long x, long long y, long long p) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (1LL * ans * x) % p;
    y = y >> 1;
    x = (1LL * x * x) % p;
  }
  return ans % p;
}
long long fastexpp(long long x, long long y, long long p) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = mulmod(ans, x, p);
    y = y >> 1;
    x = mulmod(x, x, p);
  }
  return ans % p;
}
long long invmod(long long x, long long p) { return fastexp(x, p - 2, p) % p; }
bool check_composite(long long n, long long a, long long d, int s) {
  long long x = fastexp(a, d, n);
  if (x == 1 || x == n - 1) return false;
  for (int r = 1; r < s; r++) {
    x = (1LL * x * x) % n;
    if (x == n - 1) return false;
  }
  return true;
}
bool isPrime(long long p) {
  if (p <= 1) return false;
  int r = 0;
  long long d = p - 1;
  while (!(d & 1)) {
    d >>= 1;
    r++;
  }
  for (int i = 0; i < 12; i++) {
    int value = TestMillerRabin[i];
    if (p == value) return true;
    if (check_composite(p, value, d, r)) return false;
  }
  return true;
}
int lpf[1000005];
int divisors[1000005];
void sieve() {
  for (int i = 2; i < 1000005; i++) {
    if (!lpf[i]) {
      lpf[i] = i;
      for (long long j = 1LL * i * i; j < 1000005; j += i) {
        if (lpf[j] == 0) lpf[j] = i;
      }
    }
  }
}
int phi[1000005];
void cphi() {
  phi[1] = 1;
  for (int i = 2; i < 1000005; i++) {
    if (!phi[i]) {
      phi[i] = i - 1;
      for (long long j = 2 * i; j < 1000005; j += i) {
        if (phi[j] == 0) phi[j] = j;
        phi[j] = phi[j] / i * (i - 1);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  sieve();
  cphi();
  int n, k;
  cin >> n >> k;
  if (k == 1)
    cout << 3;
  else {
    sort(phi + 1, phi + n + 1);
    long long ans = 0;
    for (int i = 1; i <= k + 2; i++) ans += phi[i];
    cout << ans;
  }
  return 0;
}
