Hyeonjeong plays a chess variant with its own rules. The board has N rows and M columns, and the super knight is the only piece she can use.
From the square it stands on, the super knight moves to a square offset by (+a,+b), (+a,−b), (−a,+b), (−a,−b), (+b,+a), (+b,−a), (−b,+a), (−b,−a). An ordinary chess knight is the case a=2 and b=1.
There are 8 candidate moves in total, but the knight cannot move to a destination that lies outside the board.
Given a, b, N, M, and k, write a program that counts the squares of the board from which exactly k moves are possible.