#include
using namespace std;
int main()
{
long long x;
cin >> x;
int n;
cin >> n;
for(int i = 0; i < n; i++) {
long long najgolem_delitel = 1;
for(long long j = 2; j * j <= x; j++) {
if(x % j == 0) {
najgolem_delitel = x / j;
break;
}
}
x += najgolem_delitel;
}
cout << x << endl;
return 0;
}