In this game, you first choose n integers with value ranges from 1 to 13. For these n integers, you can arrange them in arbitrary order, insert ‘+’, ‘-‘, ‘*’, ‘/’ and parentheses into it to guarantee the calculation result of your expression equals to m.
You may have many valid solutions for the above problem. For example, if n=4, m=24. We have two solutions: A (2,2,3,8) and B (1,5,5,5) . A has many expressions such as 3/2*8*2, 3*8*2/2,…. The expressions of B are 5*(5-1/5) and (5-1/5)*5. We say B is a valid solution as in all these expressions with the n integers in B, it includes at least a non-integer intermediate result. (The corresponding expression are 5*(5-1/5) and (5-1/5)*5, both of them contains 1/5, it is an non-integer intermediate result.) A is not a valid solution because in expression 3*8*2/2, it does not include non-integer intermediate result.
In this problem, please return the number of valid solutions of the input n and m.
Please note that permutations, such as (1,5,5,5) and (5,1,5,5) are treated as a same solution.