Triangle Hunt

Measharan Bees have built a regular triangle made of hexagonal
honeycells. Each honeycell contains some amount of honey.

[image]

Now, we want to sell exactly M units of honey. For this, we have to cut
out a triangle which contains exactly M units. We only consider regular
triangles which have a horizontal edge here.

In the picture above, there are two triangles, each of which contains 10
honeycells with 100 units of honey each. All other triangles contain a
number other than 1000 (there would be a third solution if the cell with
15 units contained 10 units).

Input

The first line of input contains two numbers N and M
(1 ≤ N ≤ 500, 1 ≤ M ≤ 50000).

The i-th of the following numbers contains i numbers, each of them in
range from 0 to 10000. The picture above corresponds to the sample.

Output

Output the number of triangles which contain exactly M units of honey.

Problem information

Author: Eryk Kopczynski

Generation: 2026-01-25T13:23:16.717Z

© Jutge.org, 2006–2026.
https://jutge.org
