// Arup Guha
// 4/9/2017
// Solution to 1992 UCF HS Contest Problem: The Lunch Machine

import java.util.*;

public class machine {

	public static void main(String[] args) {

		// Set up prices.
		HashMap<String,Integer> prices = new HashMap<String,Integer>();
		prices.put("GUM", -35);
		prices.put("CHIPS", -40);
		prices.put("SODA", -50);
		prices.put("SANDWICH", -85);
		prices.put("NICKEL", 5);
		prices.put("DIME", 10);
		prices.put("QUARTER", 25);
		prices.put("DOLLAR", 100);

		Scanner stdin = new Scanner(System.in);

		int cents = 0;

		// Process whole transcript.
		while (stdin.hasNext()) {

			String cmd = stdin.next();

			// Special command not in the HashMap.
			if (cmd.equals("CHANGE")) {
				output(cents);
				cents = 0;
			}

			// changes money in the machine.
			else {
				int value = prices.get(cmd);

				// Add a coin.
				if (value > 0)
					cents += value;

				// Buying something.
				else {

					// Can't afford it.
					if (cents + value < 0) {
						System.out.println("Insufficient funds");
					}

					// Get it!
					else {
						cents += value;
						output(cents);
						cents = 0;
					}
				}
			}
		}
	}

	// Their format - annoying, when I did %2d it didn't put a leading 0!!!
	public static void output(int cents) {
		if (cents%100 >= 10)
			System.out.printf("$%d.%d\n", cents/100, cents%100);
		else
			System.out.printf("$%d.0%d\n", cents/100, cents%100);
	}
}