import sys input=sys.stdin.readline import itertools N, K = map(int,input().split()) l = [i for i in range(1,K+1)] listed = [sorted(v,reverse=True)[1] for v in itertools.product(l, repeat=N)] print(sum(listed))