#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
struct debug {
  template <class T>
  debug& operator<<(const T&) {
    return *this;
  }
};
using ll = long long;
template <typename T>
void min_self(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void max_self(T& a, T b) {
  a = max(a, b);
}
const int inf = 1e9 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << "3\n";
    exit(0);
  }
  vector<int> phi(n + 1);
  for (int i = 0; i <= n; i++) {
    phi[i] = i;
  }
  for (int i = 2; i <= n; i++) {
    if (phi[i] == i) {
      --phi[i];
      for (int j = i + i; j <= n; j += i) {
        phi[j] = (phi[j] / i) * (i - 1);
      }
    }
  }
  debug() << "[ "
          << "phi"
             ": "
          << (phi) << " ] ";
  k += 2;
  sort(phi.begin() + 1, phi.end());
  long long ans = 0;
  for (int i = 1; i <= k; i++) {
    ans += phi[i];
  }
  cout << ans << "\n";
}
