#include <iostream>
using namespace std;
int main()
{
unsigned long long int n, a, answer;
cin >> n >> a;
if (a > 1)
{
answer = n*a;
for(unsigned long long int i = n-1; i > 0; --i)
answer = (answer+i)*a;
}
else
answer = n*(n+1)/2;
cout << answer;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7Cgl1bnNpZ25lZCBsb25nIGxvbmcgaW50IG4sIGEsIGFuc3dlcjsKCWNpbiA+PiBuID4+IGE7CglpZiAoYSA+IDEpCgl7CgkJYW5zd2VyID0gbiphOwoJCWZvcih1bnNpZ25lZCBsb25nIGxvbmcgaW50IGkgPSBuLTE7IGkgPiAwOyAtLWkpCgkJCWFuc3dlciA9IChhbnN3ZXIraSkqYTsKCX0KCWVsc2UKCQlhbnN3ZXIgPSBuKihuKzEpLzI7Cgljb3V0IDw8IGFuc3dlcjsKCXJldHVybiAwOwp9