import re;a=re.sub while 1:print a('\^1|[-+x]+\d*$','',a('(\d+)x\^((.))',lambda m:eval('`%s*%s`+"x^"+`~-%s`'%m.groups()),raw_input()))