1. JAVA, Peter Schnitzler

/* Problem : 10523
* Author : Peter Schnitzler
* Status : AC
* Runtime : 0.650
*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;


public class Main
{

/**
* @param args
*/
public static void main(String[] args) throws Exception
{
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

String line = read.readLine();

while (line != null)
{
StringTokenizer tok = new StringTokenizer(line);

int n = Integer.parseInt(tok.nextToken());

BigInteger aRun = new BigInteger(tok.nextToken());

BigInteger a = aRun.add(BigInteger.ZERO);

BigInteger total = BigInteger.ZERO;
BigInteger bigCount = BigInteger.ONE;

for (int count = 1; count <= n; count++)
{
total = total.add(bigCount.multiply(aRun));
aRun = aRun.multiply(a);
bigCount = bigCount.add(BigInteger.ONE);
}

System.out.println(total);

line = read.readLine();
}
}

}