#!/usr/bin/python

# Author: Peter Schwabe
# Date: 2009-03-19
# Public domain

import re
import sys

rstr = "\$[^\$]*\$"
r = re.compile(rstr)
for line in sys.stdin.readlines():
    while True:
        exp = r.search(line)
        if exp:
       	    s = "a="+re.sub("\$","",exp.group())
            exec(s)
            line = re.sub(rstr,str(a),line,1)
        else:
            break
    print line,
	
