#K56132. Treasure Distribution

    ID: 30131 Type: Default 1000ms 256MiB

Treasure Distribution

Treasure Distribution

You are given two positive integers N and M. Your task is to determine in how many ways you can distribute exactly M pieces of treasure among N members such that each member receives a distinct positive integer amount. In other words, if the members receive amounts a1, a2, ..., aN respectively, then:

(1) Each ai is a positive integer.
(2) ai ≠ aj for all i ≠ j.
(3) The sum of all amounts equals M, i.e.
$$a_1 + a_2 + \cdots + a_N = M.$$

It can be observed that the minimum possible sum when giving distinct positive integers is obtained when the members receive the first N natural numbers. This sum is given by:

$$S = \frac{N(N+1)}{2}.$$

If S = M, then there is exactly one way to distribute the treasure. Otherwise, it is impossible under the constraints described here.

Your task is to output 1 when S equals M and 0 otherwise.

inputFormat

The input consists of a single line containing two space-separated integers N and M, where:

  • N corresponds to the number of members,
  • M is the total number of treasure pieces.

outputFormat

Output a single integer: 1 if there is exactly one way to distribute the treasure (i.e. if M = \frac{N(N+1)}{2}), or 0 otherwise.

## sample
2 3
1

</p>