Between Ceiling and Floor √√

Given positive integers m and k, let f (x, y) = x⌈y k⌉ − y⌊x k⌋, compute the number of positive integer pairs (a, b) such that f (a, b) = m, f (a − b, b) ̸= m, and f (a, b − a) ̸= m hold simultaneously. Input A number of of inputs (≤ 1000) described as follows. Each input is just a single line with m and k (0 < m,k ≤ 1018). Output For each input, output a line with the number of pairs. Sample Input 34 35 Sample Output 0 4