favorite We need a little bit of your help to keep things running, click on this banner to learn more

Product sum

Product sum

There is a set of variables x1, x2, ..., xN. Each variable xi can be assigned the value -1, 0, +1 only. For a given integer p you are to calculate the number of ways variables xi can be assigned values so that the sum of all possible products xi·xj is equal to S, where i < j and i, j = 1, 2, ..., N. Two ways are considered different if they contain a different number of xi = 0.


The input file contains two numbers: N and S, separated by space.

2N10000, -10000 < S < 10000.


The output file should contains only one integer – the number of ways to represent S as a sum of products.

Time limit 1 second
Memory limit 64 MiB
Input example #1
5 0
Output example #1