Luka found a very unusual game board in his attic. Surprisingly, it consists of square cells. The rows are numbered to top to bottom and the columns to left to right.
What makes the board unusual is the way in which the cells are coloured. Each cell is either grey or white:
- white, if the row and column numbers of the cell, when represented in binary, have at least one digit 1 in the same position. For example, the cell would be white.
- grey, otherwise. For example, the cell would be grey.
The following image shows a board of size .
Luka's hedgehog likes walking on this unusual board and does it in an unusual way. The hedgehog starts his walk in the cell and continues in the zig-zag pattern as in the second image above. While the hedgehog is walking, Luka counts how many grey squares it visited.
After visiting squares, the hedgehog gets tired and falls asleep. Luka then goes to bed too, happy that he was able to count the grey squares.
Knowing the dimensions of the board and the number beforehand, however, it is possible to write a program that calculates the result faster. This is your task.
Input Specification
The first line contains two integers and , the dimensions of the board.
The second line contains the integer , the total number of squares the hedgehog visits.
Note that this number may not fit in a -bit integer.
Output Specification
Output the number of grey cells the hedgehog visits.
Grading
In test cases worth of points, will be less than .
Sample Input 1
10 10
6
Sample Output 1
5
Sample Input 2
3 5
11
Sample Output 2
8
Sample Input 3
10 10
100
Sample Output 3
51
Comments