PHP Compiler Testing
Linear Congruence

Have the function LinearCongruence(str) read the str parameter being passed which will be a linear congruence equation in the form: "ax = b (mod m)" Your goal is to solve for x and return the number of solutions to x. For example: if str is "32x = 8 (mod 4)" then your program should return 4 because the answers to this equation can be either 0, 1, 2, or 3.

Examples

Input: "12x = 5 (mod 2)"
Output: 0

Input: "12x = 4 (mod 2)"
Output: 2