#include <bits/stdc++.h>
using namespace std;
int const INF = (int)1e9 + 1e3;
long long const INFL = (long long)1e18 + 1e6;
mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
uniform_int_distribution<long long> ll_distr;
long long rnd(long long a, long long b) {
  return ll_distr(tw) % (b - a + 1) + a;
}
const int MAXN = 1e6 + 5;
int sieve[MAXN];
int weight(int num) {
  if (num == 3) {
    return 3;
  }
  if (num == 4) {
    return 3;
  }
  set<int> primes;
  int mem = num;
  while (sieve[num] != 0) {
    primes.insert(sieve[num]);
    num /= sieve[num];
  }
  primes.insert(num);
  for (int p : primes) {
    mem = mem / p * (p - 1);
  }
  return mem;
}
void solve() {
  int n, k;
  cin >> n >> k;
  if (n == 3) {
    cout << "3\n";
    return;
  }
  set<pair<int, int> > qu;
  vector<bool> used(n + 1);
  vector<int> cnt_prev(n + 1);
  qu.insert({weight(4), 4});
  vector<int> prarr;
  for (int i = 2; i <= n; ++i) {
    if (sieve[i] == 0) {
      prarr.push_back(i);
      if (i > 2) {
        qu.insert({weight(i), i});
      }
      for (int j = i * 2; j <= n; j += i) {
        sieve[j] = i;
      }
    }
  }
  for (int i = 3; i <= n; ++i) {
    set<int> pr;
    int tmp = i;
    while (sieve[tmp]) {
      pr.insert(sieve[tmp]);
      tmp /= sieve[tmp];
    }
    pr.insert(tmp);
    cnt_prev[i] = ((int)pr.size());
  }
  long long ans = 0;
  fill(used.begin(), used.end(), 0);
  for (int i = 0; i < k; ++i) {
    ans += qu.begin()->first;
    int num = qu.begin()->second;
    qu.erase(qu.begin());
    for (int p : prarr) {
      long long to = p * num;
      if (to > n) {
        break;
      }
      --cnt_prev[to];
      if (cnt_prev[to] == 0) {
        qu.insert({weight(to), to});
      }
    }
    if (num == 4) {
      for (int p : prarr) {
        long long to = p * 2;
        if (to == 4) {
          continue;
        }
        if (to > n) {
          break;
        }
        --cnt_prev[to];
        if (cnt_prev[to] == 0) {
          qu.insert({weight(to), to});
        }
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  cout << setprecision(15) << fixed;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_count = 1;
  for (int test = 1; test <= test_count; ++test) {
    solve();
  }
}
