#K82517. Equalizing Digits

    ID: 35993 Type: Default 1000ms 256MiB

Equalizing Digits

Equalizing Digits

You are given a positive integer \(n\) and an integer \(k\) representing the maximum number of operations allowed. In one operation, you can choose any digit in \(n\) and increment it by \(1\). If the digit is \(9\), it wraps around to \(0\) (i.e. increasing \(9\) gives \(0\)).

Your task is to determine whether it is possible to make all the digits in \(n\) equal using at most \(k\) operations.

For a digit \(d\) and a target digit \(t\), the cost to change \(d\) to \(t\) is computed as:

\[ cost(d,t)=\begin{cases} t-d, & \text{if } d \le t\\ 10-d+t, & \text{if } d > t \end{cases} \]

You need to choose a target digit \(t\) (from 0 to 9) such that the total cost over all digits is at most \(k\). Output YES if it is possible, otherwise output NO.

inputFormat

The input consists of a single line containing a string representing the integer \(n\) and an integer \(k\), separated by space.

\(n\) may be large so it is provided as a string.

Example: 55678 10

outputFormat

Output a single line: YES if it's possible to make all the digits equal with at most \(k\) operations, or NO otherwise.

## sample
999 1
YES