#B3620. Base Conversion

    ID: 11280 Type: Default 1000ms 256MiB

Base Conversion

Base Conversion

Given a small integer \(x\) representing the base and a number \(S\) expressed in base \(x\), convert \(S\) to its decimal (base 10) representation. For digits beyond 9, characters 'A', 'B', ... are used. The conversion follows the formula:

$$S = \sum_{i=0}^{n-1} d_i \times x^{n-1-i}$$

where \(d_i\) is the digit at the \(i\)th position.

inputFormat

The input consists of a single line containing an integer \(x\) (the base) and a string \(S\) representing the number in base \(x\), separated by a space. Note that for digits greater than 9, uppercase letters are used.

outputFormat

Output the decimal (base 10) equivalent of the number \(S\).

sample

10 123
123