#include <bits/stdc++.h>
using namespace std;
int Total, Can;
bool Visit[1000001];
int Prime[1000001];
int Phi[1000001];
vector<int> Edge;
int main(void) {
  register int i, j;
  cin >> Total >> Can;
  if (Can == 1) {
    cout << 3;
    return 0;
  }
  Phi[1] = 1;
  Visit[1] = true;
  register long long Ans;
  Ans = 2;
  register int Count;
  Count = 0;
  for (i = 2; i <= 1000000; i++) {
    if (!Visit[i]) {
      Prime[Count] = i;
      Phi[i] = i - 1;
      Count++;
    }
    for (j = 0; j < Count && Prime[j] * i <= 1000000; j++) {
      Visit[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);
    }
  }
  for (i = 3; i <= Total; i++) {
    Edge.emplace_back(Phi[i]);
  }
  sort(Edge.begin(), Edge.end());
  for (i = 0; i < Can; i++) {
    Ans += Edge[i];
  }
  cout << Ans << endl;
  return 0;
}
