#include <bits/stdc++.h>
using namespace std;
void io() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
long long ans = 1;
int n, k, cnt;
const int maxn = 1000000;
bool vis[maxn + 5];
int prime[maxn + 5];
int phi[maxn + 5];
void Phi() {
  phi[1] = 1;
  vis[1] = true;
  for (int i = 2; i <= maxn; i++) {
    if (!vis[i]) prime[cnt++] = i, phi[i] = i - 1;
    for (int j = 0; j < cnt && prime[j] * i <= maxn; j++) {
      vis[prime[j] * i] = 1;
      if (i % prime[j] == 0) {
        phi[i * prime[j]] = phi[i] * prime[j];
        break;
      }
      phi[i * prime[j]] = phi[i] * (prime[j] - 1);
    }
  }
}
vector<int> v;
int main() {
  io();
  cin >> n >> k;
  Phi();
  for (long long i = 3; i <= n; ++i) {
    v.emplace_back(phi[i]);
  }
  sort(v.begin(), v.end());
  for (long long i = 0; i <= k - 1; ++i) {
    ans += v[i];
  }
  if (k > 1) ++ans;
  cout << ans;
}
