#include <bits/stdc++.h>
using namespace std;
const int M = 5000001;
int n, m, k, ph[M], p[M], P, b[M];
long long res;
void Ph(int n) {
  ph[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!b[i]) p[++P] = i, ph[i] = i - 1;
    for (int j = 1; j <= P && p[j] * i <= n; j++) {
      b[i * p[j]] = 1;
      if (i % p[j] == 0) {
        ph[i * p[j]] = ph[i] * p[j];
        break;
      }
      ph[i * p[j]] = ph[i] * (p[j] - 1);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  if (m == 1) {
    printf("3");
    return 0;
  }
  Ph(n);
  sort(ph + 1, ph + 1 + n);
  for (int i = 3; i <= m + 2; i++) res += (long long)ph[i];
  printf("%I64d", res + 2ll);
}
