Mike graduated from high school several years ago. One day a question suddenly comes to his mind: how many classmates did he have in his high school? He doesn’t remember, and it's obviously too hard for him to recall everyone. But he does remember something - a game played on a New Year's Day. Because all his classmates had joined that game, Mike thinks he can figure out the number of his classmates by some clues.
The game went like this: At first, all classmates stood one by one in a circle, labeled clockwisely from No.1 to No. n. Of course n is the total number of all classmates. Then, starting from the No. 2 guy, they kicked out every 2nd guy. After each guy was kicked out, counting and kicking continued around the circle that remained, until there was only one guy left. That luck guy would get a gift. As shown in the picture below, if there were 6 classmates in the game, the people been kicked out would be in the order of No.2, No.4, No.6, No.3 and No.1, and in the end the No. 5 guy would win the gift.
Mike can only remember what number he was labeled, and how many classmates still remained in the circle when he was going to be kicked out. You should help him calculate the minimum possible total number of his classmates.