eolymp
bolt
Try our new interface for solving problems
Problems

Cash machine

Cash machine

Time limit 1 second
Memory limit 128 MiB

In the ATM, there are sufficient banknotes with denominations of 10, 20, 50, 100, 200, and 500 hryvnias. Find the minimum number of banknotes needed to dispense the amount of n hryvnias.

Input data

One integer n~(1 \le n \le 10^6).

Output data

Print the minimum number of banknotes needed to dispense n hryvnias. Print -1 if the specified amount cannot be dispensed.

Examples

The sum of 770 hryvnia can be dispensed as follows: 500 + 200 + 50 + 20.

Input example #1
770
Output example #1
4