링크 : https://www.acmicpc.net/problem/5585
/*
문제 : 거스름돈
링크 : https://www.acmicpc.net/problem/5585
*/
#include <iostream>
#include <vector>
using namespace std;
int main(){
int cost;
cin >> cost;
cost = 1000 - cost;
vector<int> v = {500, 100, 50, 10, 5, 1};
int cnt = 0;
for(int i = 0; i < v.size(); i++){
while(cost - v[i] >= 0){
cnt ++;
cost -= v[i];
}
}
cout << cnt;
return 0;
}