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