total = 0

money = [1000, 100, 25, 1]
m_cnt = []

for i in range(3):
    total += money[i + 1] * int(input())

for i in range(4):
    m_cnt.append(total // money[i])
    total -= m_cnt[i] * money[i]
    
print(sum(m_cnt[1:4]))