e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

Cash machine

Cash machine

The cash machine contains the sufficient number of banknotes with denominations 10, 20, 50, 100, 200 and 500 hryvnias. Find the minimum number of bills to give an amount of n hryvnias or print -1 if its impossible.

Input

One number n (1n1000000).

Output

Print the minimum number of banknotes to give n hryvnias or -1 if its impossible.

Time limit 1 second
Memory limit 64 MiB
Input example #1
770
Output example #1
4