Vending Machine

Time limit1sMemory limit256 MB

Summary
Given a sequence of vending machine button presses with fixed prices, subtract the total cost from 5000 won and print the change.
Level

Easy2 of 10

Topics
Implementation, Math, Simulation
Solved
No attempts yet

Problem

Jeongung took the 5000 won allowance from his mother and went to a vending machine.

The vending machine has three buttons.

  • Pressing 1 gets him a 500 won Lessbi.
  • Pressing 2 gets him an 800 won Gatorade.
  • Pressing 3 gets him a 1000 won Coca-Cola.

Given the sequence of button numbers he pressed, find the change. He never presses a button that would exceed the money he has.

Input

The first line gives the numbers of the buttons Jeongung pressed, separated by spaces. Jeongung pressed at least one button.

Output

Print the change the vending machine returns on the first line.

Examples1

  1. Example 1

    Input
    1 2 3
    
    Expected output
    2700