614. Sum of Numbers With Units Digit K

0

Medium

Given two integers num and k, find the minimum possible size of a set of positive integers that satisfies the following conditions:
1. The units digit of each integer in the set is k.
2. The sum of all integers in the set is equal to num.
If no such set exists, output -1.
Note:
- The set can contain multiple instances of the same integer.
- The sum of an empty set is considered 0.
- The units digit of a number refers to the rightmost digit of the number.

Input Format

The input consists of two lines:
- The first line contains the value of num.
- The second line contains the value of k.

Output Format

Output a single integer, which represents the minimum possible size of a valid set. If no such set exists, output -1.

Example

Input

58
9

Output

2

Constraints

0 <= num <= 3000

0 <= k <= 9

0 <= k <= 9

Loading...

View Submissions

Console