#include <bits/stdc++.h>
using namespace std;
vector<long long int> p;
void sieve() {
  vector<long long int> isPrime(1000001, 1);
  for (long long int i = 2; i <= 1000000; i++) {
    if (isPrime[i] == 1) {
      p.push_back(i);
      for (long long int j = 2; i * j <= 1000000; j++) isPrime[i * j] = 0;
    }
  }
}
long long int phi(long long int n) {
  long long int res = n;
  for (long long int i = 0; p[i] * p[i] <= n; i++) {
    if (n % p[i] == 0) {
      res -= (res / p[i]);
      while (n % p[i] == 0) n /= p[i];
    }
  }
  if (n > 1) res -= (res / n);
  return res;
}
int main() {
  sieve();
  long long int n, k, ans = 2;
  cin >> n >> k;
  vector<long long int> A(n - 2);
  if (k == 1) {
    cout << 3 << endl;
    return 0;
  }
  for (long long int i = 3; i <= n; i++) {
    A[i - 3] = phi(i);
  }
  sort(A.begin(), A.end());
  for (long long int i = 0; i < k; i++) {
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}
