#include <fstream>
using namespace std;
ifstream f1("dqu.inp");
ofstream f2("dqu.out");
long long n,tong = 0,i;
long long tinh(long long a,long long b)
{
    long long tg = a;
    for (long long n = 1; n < b; n++)
    {
        a = a * tg;
    }
    return a;
}
void ts(long long n)
{
    if (n > 0) {tong = tong + tinh(n,i);ts(n-1);}
}
int main()
{
    f1 >> n >> i;
    ts(n);
    f2 << tong;
    return 0;
}
