a=int(input())*100 b=int(input())*25 c=int(input())*1 d=(a+b+c)%1000 e=d//100 f=(d-(e*100))//25 g=d-(e*100)-(f*25) print(g)