Problem G: m-Points Game

## Problem G: m-Points Game

Time Limit: 3 Sec  Memory Limit: 128 MB
Submit: 176  Solved: 32
[Submit][Status][Web Board]

## Description

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.

## Input

The only line of input contains only two integers:

$$n(1 \leq n \leq 4), m (1 \leq m \leq 10^9)$$

## Output

The number of valid solutions.

## Sample Input

4 159

## Sample Output

8


## HINT

The correspond solutions to the sample is :

2,8,12,13

3,12,12,13

3,12,13,13

4,5,12,12

4,9,11,12

4,10,12,13

8,10,12,12

10,13,13,13

[Submit][Status]