#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
bool prime[N];
int phi[N], deg[N];
void sieve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  sieve();
  int n, k;
  cin >> n >> k;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      q;
  for (int i = 3; i <= n; ++i) {
    if (deg[i] == 0) {
      q.push({phi[i], i});
    }
    for (int j = 2 * i; j <= n; j += i) {
      ++deg[j];
    }
  }
  long long ans = (k == 1 ? 1 : 2);
  while (k--) {
    auto cur = q.top();
    q.pop();
    int i = cur.second;
    ans += phi[i];
    for (int j = 2 * i; j <= n; j += i) {
      --deg[j];
      if (deg[j] == 0) {
        q.push({phi[j], j});
      }
    }
  }
  cout << ans << '\n';
}
void sieve() {
  for (int i = 2; i < N; ++i) {
    prime[i] = true;
    phi[i] = i;
  }
  for (int i = 2; i < N; ++i) {
    if (prime[i]) {
      for (int j = i; j < N; j += i) {
        prime[j] = false;
        phi[j] /= i;
        phi[j] *= (i - 1);
      }
    }
  }
}
