#P8629. [蓝桥杯 2015 国 C] 机器人繁殖

[蓝桥杯 2015 国 C] 机器人繁殖

Description

Robots in the X galaxy can copy themselves automatically. In 11 year, each robot can reproduce 22 copies of itself, and then it loses the ability to reproduce.

Every year, the X galaxy will select 11 newly born robot and send it into space. That is, if the X galaxy originally has 55 robots, then:
After 11 year, the total number is: 5+9=145 + 9 = 14.
After 22 years, the total number is: 5+9+17=315 + 9 + 17 = 31.

If you have already observed that after nn years the total number of robots is ss, can you calculate how many robots there were at the beginning?

Input Format

Input one line with two numbers nn and ss, separated by spaces, with the meanings as described above. nn is not greater than 100100, and ss has at most 5050 digits.

Output Format

Output one line with one integer, indicating how many robots there were at the beginning.

2 31
5
97 2218388550399401452619230609499
8

Hint

Time limit: 11 second, 512M512\text{M}. Lanqiao Cup 2015, 6th National Finals.

Translated by ChatGPT 5