Base Conversion

Time limit1sMemory limit128 MB

Problem

You are given a number N written in base B. Write a program that converts N to decimal and prints the result.

In bases greater than 10, a single digit can have a value greater than 9. Values from 10 through 35 are represented by uppercase letters A through Z.

A: 10, B: 11, ..., F: 15, ..., Y: 34, Z: 35

Input

The first line contains the base-B number N and the base B, separated by a space. (2 <= B <= 36)

The decimal value of N is always at most 1,000,000,000.

Output

Print the decimal value of N on the first line.