super95
문제
This task is based on the pronunciation of integers in the Croatian language. The following table lists pronunciation rules for some of the numbers. All numbers that don't fit into the table start with the same letter as the first digit in them.
| 1 | jedan | 10 | deset | 1xx | sto |
|---|---|---|---|---|---|
| 2 | dva | 11 | jedanaest | 1xxx | tisuću |
| 3 | tri | 12 | dvanaest | 1xxxx | deset tisuća |
| 4 | četiri | 13 | trinaest | 1xxxxx | sto tisuća |
| 5 | pet | 14 | četrnaest | 1xxxxxx | milijun |
| 6 | šest | 15 | petnaest | 1xxxxxxx | deset milijuna |
| 7 | sedam | 16 | šesnaest | 1xxxxxxxx | sto milijuna |
| 8 | osam | 17 | sedamnaest | 1xxxxxxxxx | milijarda |
| 9 | devet | 18 | osamnaest | 1xxxxxxxxxx | deset milijardi |
| 19 | devetnaest | 1xxxxxxxxxxx | sto milijardi |
Consider the sequence of positive integers whose pronunciation starts with the given letter.
For example, for the letter P the sequence is:
5, 15, 50, 51, 52, ..., 59, 500, 501, ...
Write a program that finds the N-th number in the sequence of numbers whose pronunciation starts with the given letter.
입력
The first and only line of input contains a single letter (one of 'D', 'J', 'M', 'O', 'P', 'S' or 'T') and an integer N.
Note: the test cases will be such that the solution will be less than 1012 (use 64-bit integral types – int64 in Pascal, long long in C/C++).
출력
Output the required number on a single line.
예제
예제 1
S 1
7
예제 2
P 13
500
예제 3
M 1000006
1000000005