Problem: The mysterious pathogen of ACM Nation multiplies mysteriously each day. Maria was able to

decipher the pattern but unable to completely solve the problem. The study of this equation will 

help in combating their growth. 

The summation is - 

S = a + aa + aa*a + ...... a^n times

Where a is the number of pathogen on the first day and S on the nth day.

Input : a and n are taken as input from the user.   First line will contain a,followed by n. 

Output: a single integer depicting the sum

Sample Input:
2
4

Sample Output:
30

SAMPLE INPUT
2
4

SAMPLE OUTPUT
30

Solution (in PYTHON):

Solution:
'''
# Read input from stdin and provide input before running code
 
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
sum=0
a=int(raw_input())
n=int(raw_input())
i=1
while i<=n:
	sum=sum+pow(a,i)
	i=i+1
print sum