#include <bits/stdc++.h>   using namespace std;   int a[1000001];   int main() {     int n, k;     cin >> n >> k;     if (k == 1) return puts( 3 ), 0;     for (int i = 1; i <= n; i++) a[i] = i;     for (int i = 2; i <= n; i++)       if (a[i] == i) {         for (int j = i; j <= n; j += i) a[j] = (a[j] / i) * (i - 1);       }     sort(a + 3, a + n + 1);     cout << accumulate(a + 3, a + k + 3, 0ll) + 2 << endl;     return 0;   }   