Category

Similar Problems

0779. Cash machine

Time limit : 1000 ms
Memory limit : 64 mb

The cash machine contains the sufficient banknotes of denominations 102050100200 and 500 hryvinias. Find the minimum number of bills that can be used to give an amount of n hryvnias or print -1 if its impossible.

Input

One integer number n (1 ≤ n ≤ 109).

Output

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

Input

Output

1

770

4

 

Tayyorladi: Azat Yusupov
Text from: e-olimp.com