Casino
Michael Corleone decided to open a new casino in Las-Vegas, Nevada. His personal favorite game is a special version of the roulette game, there five players use the roulette wheel.
There are N slots on the table, each slot has the card with a number from 1 to N. All cards have different numbers. Initially the cards are ordered, that is, the 1^st card is in the 1st slot, the 2^nd card is in the 2^nd slot and etc. In other words, initially every card is in the right position - that is, the number of the card and the number of the slot match.
The game consists of M moves made by players. Let's call players A, B, C, D and E. Here is how they play:
Player A makes the first move. He takes the last card out of the last N^{-th} slot. After that he moves all the cards in slots [1 ... (N-1)] one slot right. That is, the 1^st card moves to the 2^nd slot, the 2^nd card moves to the 3^rd slot and etc. After that the 1^st slot becomes empty. Player A puts the last card in the 1^st slot.
Player B makes the second move. He takes the last card from the last N^{-th} slot. After that he moves all the cards in slots [(N–N/2) ... (N-1)] one slot right. After that he puts the card that he has on his hands in empty slot. In other words, he does the same thing as the first player, but for the range [(N-N/2) ... N].
Player C makes the third move. He takes the card from the slot with number N/4. After that he moves all the cards in slots [1 ... (N/4-1)] one slot right. After that he puts the card that he has on his hands in empty slot.
Played D makes the fourth move. He takes the card from the last N^{-th} slot. After that he moves all the cards in slots [(N–N/6) ... (N-1)] one slot right. After that he puts the card that he has on his hands in empty slot. In other words, he does the same thing as the first player, but for the range [(N–N/6) ... N)].
Player E makes the fifth move. He takes the card from the slot with number N/8. After that he moves all the cards in slots [1 ... (N/8-1)] one slot right. After that he puts the card that he has on his hands in empty slot.
After that the game repeats, until M moves are made. That is, if there are 7 moves, then the sequence of player moves is ABCDEAB, that is players A and B make two moves, but other players make just one move.
Now, you have decided to make a bet on the card positions after M moves. According to casino rules, if you make a bet in the beginning of the game on card positions after M moves, you will get L dollars for that, where L is the number of cards in the right position after M moves.
For example, suppose there are 20 slots on the table and you made a bet on three moves. Players A, B and C make a move each. After that suppose only three cards are in the right position - 3, 10 and 17. That means you will get 3 dollars from the casino, if you make such a bet. You would like to know in advance how much you can win.
Input
The input consists of two numbers N and M (40 ≤ N ≤ 126, 1 ≤ M < 10^9) separated by spaces.
Output
The output should contain a single number L - the number of dollars the casino will pay you after M moves.