local n = io.read("*n", "*l") local s = io.read() local stack = {} for w in s:gmatch("%g+") do if w == "+" then local v1 = stack[#stack - 1] local v2 = stack[#stack] stack[#stack - 1] = v1 + v2 table.remove(stack) elseif w == "-" then local v1 = stack[#stack - 1] local v2 = stack[#stack] stack[#stack - 1] = v1 - v2 table.remove(stack) else table.insert(stack, tonumber(w)) end end print(stack[1])