#C2817. Minimum Candies Distribution Difference

    ID: 46175 Type: Default 1000ms 256MiB

Minimum Candies Distribution Difference

Minimum Candies Distribution Difference

You are given two integers \(N\) and \(M\) representing the number of candies and the number of children respectively. The candies are to be distributed as evenly as possible among the children.

If \(N\) can be equally divided among \(M\) children (i.e. \(N \mod M = 0\)), then every child receives the same number of candies and the difference between the maximum and minimum is \(0\). Otherwise, some children receive one candy more than others, and the difference becomes \(1\). In the special case where \(M=0\), output \(0\) since there are no children to distribute the candies.

Examples:

  • For \(N=7\) and \(M=3\), one possible distribution is \(3,2,2\), so the difference is \(1\).
  • For \(N=10\) and \(M=5\), each child gets \(2\) candies resulting in a difference of \(0\).
  • For \(N=9\) and \(M=6\), the distribution yields a difference of \(1\) as it is impossible to divide equally.

inputFormat

The input consists of a single line containing two space-separated integers \(N\) and \(M\), where \(N\) is the number of candies and \(M\) is the number of children.

outputFormat

Output a single integer representing the minimum possible difference between the maximum number of candies and the minimum number of candies that any child receives.

## sample
7 3
1

</p>