price = int(input())
coins = [500, 100, 50, 10, 5, 1]
change = (1000 - price)
count = 0
for coin in coins:
    Q, R = divmod(change, coin)
    count = count + Q
    change = R
    if R == 0:
        break
print (count)

 

#include <iostream>
#include <math.h>
using namespace std;

int main(void)
{
	int C = 0;
	int N = 0;
	
	cin >> C;
	
	for (int i=0; i<C; i++) // This loop means the number of test case.
	{
		cin >> N;
		
		if (N>=1 and N<=1000)
		{
			int Sum = 0;
			double Mean = 0;
			double count = 0;
			double percent = 0;
			
			int Score[N] = {0, };
			
			for (int j=0; j<N; j++) // This loop gets the summation of input values
			{
				cin >> Score[j];
				if (Score[j]< 0 or Score[j]>100)
					return 0;
					
				Sum = Sum + Score[j];
			}
			
			Mean = Sum / N;
			
			for (int k=0; k<N; k++) // This loop gets count of people who has higher value than mean
			{
				if (Score[k] > Mean)
				{
					count = count + 1;
				}
			}
			
			percent = (count/N) * 100;
			cout << fixed;
			cout.precision(3);
			cout << round(percent * 1000) / 1000 << "%" << endl;
		}
	}
	return 0;
}
for _ in range(30000):
    length = list(map(int, input().split()))
    length = sorted(length, reverse=True)

    if pow(length[0], 2) == 0 and length[1] == 0 and length[2] == 0:
        break

    if pow(length[0], 2) == pow(length[1], 2) + pow(length[2], 2):
        print ("right")
    else:
        print ("wrong")
import sys
import math
input = sys.stdin.readline
R = int(input())
print (round(math.pi * pow(R, 2), 6))
print (round(R * R * 2, 6))
#include <iostream>
using namespace std;

int solution1()
{
	int array[10] = {0, };
	int remainder[42] = {0,};
	int count = 0;
	
	for (int i=0; i<10; i++)
	{
		cin >> array[i];
		
		if (array[i] < 0 or array[i] > 1000)
			return 0;
		
		if (!remainder[array[i] % 42]++)	
			count = count + 1;
	}
	return count;
}



int main(void)
{
	int count = 0;
	count = solution1();
	cout << count << endl;
	
	return 0;
}
import sys
from collections import Counter
input = sys.stdin.readline

def get_square_coordinate(coordinates):
    X, Y = [], []
    for xy in coordinates:
        X.append(xy[0])
        Y.append(xy[1])

    cnt_x = Counter(X).most_common()
    cnt_y = Counter(Y).most_common()
    return cnt_x[-1][0], cnt_y[-1][0]
    
coordinates = []
for _ in range(3):
    coordinates.append(list(map(int, input().split())))

x, y = get_square_coordinate(coordinates)
print (x, y)
crotia = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z=']
word = input()

for i in crotia:
    word = word.replace(i, '*')

print (len(word))
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(void)
{
	string a, b;
	cin >> a >> b;
	if (a.size() == 3 and b.size() == 3)
	{
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		if (a > b)
			cout << a;
		else
			cout << b;
	}
	return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;

int main(void)
{
	int H = 0;
	int M = 0;
	int T = 45;
	
	cin >> H >> M;
	
	if ((H>=0 and H<=23) and (M>=0 and M<=59))
	{
		
		if (M-T >= 0) // M이 45분보다 커서 자릿수 내림이 발생하지 않을 때 
		{
			cout << H << " " << M-T << endl;
		}
		
		if((M-T < 0) and (H-1>=0))
		{
			cout << H-1 << " " << M-T+60 << endl;
		}
		
		else if((M-T < 0) and (H-1<0))
		{
			cout << H-1+24 << " " << M-T+60 << endl;
		}
		
	}
	
	return 0;
}
import sys
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
team = 0

# my fault
# intern = 0
# while True:
#     if N//2 >= M:
#         N = N-1
#         intern = intern + 1
#         if K == intern:
#             break
    
#     elif N//2 < M:
#         M = M -1
#         intern = intern + 1
#         if K == intern:
#             break

# t1 = N // 2
# t2 = M 
# print(min(t1, t2))

while True:
    N = N - 2
    M = M - 1
    if N < 0 or M < 0 or (N+M) < K:
        break
    team = team + 1
print (team)

+ Recent posts