How Many Solutions?

Given the values of three integers m, n, p how many integer solutions does the following equation have? mx + ny = p1 Input The input file contains at most 1001 sets of inputs. Each set of input is given in a single line containing three integers which denotes the values of m, n and p respectively. Input is terminated by a case where the value of m, n and p (−1000 ≤ m, n, p ≤ 1000) is zero. Output For each set of input produce one line of output which contains the serial of output followed by an integer N which indicates how many solutions are there for the given value of m, n and p. Comment: The equation corresponding to the first sample input is: x1 + y2 = 14 and the 11 solutions corresponding to this equation is: -28 7 -12 6 -4 4 2 -8 3 -24 5 40 6 24 8 16 12 12 20 10 36 9 Sample Input 124 234 000 Sample Output Case 1: 11 Case 2: 23