LogiQuest

144. Any Base to Decimal

EasyNumber Bases

Convert a number written in base b (digits 0–9, A–Z) to decimal.

Input format

A single line: s b

Output format

The decimal value.

Example 1

Input

FF 16

Output

255

Example 2

Input

1010 2

Output

10

Constraints

2 ≤ b ≤ 36 value ≤ 10¹⁸

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…