Hopping Jack is standing at the bottom of a long flight of stairs. The bottom of the stairs has number , first step has number , the next step has number , and so on upto infinity.
Jack will now perform consecutive actions. The actions are numbered through , in that particular order. When performing action , Jack chooses between two options: either he does nothing or he hops exactly X steps up the stairs.
In other words, if Jack starts performing action standing on step , he will end it either on step , or on step.
For example, if , Jack will make three consecutive choices: whether or not to hop step upwards, steps upwards, and then steps upwards. One of the steps is broken. The number of this step is . Jack cannot hop onto this step.
You are given the integers and . Compute and print the number of the topmost step that can be reached by Jack provided that Jack starts from the bottom of the stairs at step 0?