#C1814. Galactic Base to Decimal Conversion

    ID: 45061 Type: Default 1000ms 256MiB

Galactic Base to Decimal Conversion

Galactic Base to Decimal Conversion

You are given a number represented in a galactic numeral system with base \(B\) (where \(2 \leq B \leq 36\)). The digits of the number are provided as a string \(S\), which may contain numerals (0-9) and letters (A-Z or a-z). Your task is to convert this number from its base \(B\) representation to its equivalent decimal (base-10) number. The conversion follows the formula:

\[ \text{Decimal Value} = \sum_{i=0}^{n-1} d_i \times B^i \]

where \(d_i\) represents the value of the digit at the \(i\)-th position from the right (with \(0 \leq d_i < B\)). Note that the letters in \(S\) are case-insensitive.

inputFormat

The input consists of two lines. The first line contains an integer \(B\), the base of the numeral system. The second line contains the string \(S\) representing the number in base \(B\).

outputFormat

Output a single line containing the decimal (base-10) equivalent of the number \(S\).

## sample
16
1A
26