# evalsum.py
# Written by Todd Wareham for CS 2500
"""
Given integers n and m as command-line arguments, compute and output the 
 value of the nested summation sum{i = 2 to n} sum{j = 1 to m} i^j, where 
 i^j is i raised to the jth power.
"""

import sys

if len(sys.argv) != 3:
    print "usage:", sys.argv[0], " n m"
    sys.exit(1)

n = int(sys.argv[1])
m = int(sys.argv[2])

sum = 0
for i in range(2,n + 1):
    for j in range(m + 1):
        sum += i ** j

print sum

