#ifndef AST_HPP
#define AST_HPP

#include <cmath>
#include <memory>

#define override

typedef double number;

struct node_base
{
	virtual number evaluate() const = 0;
	virtual ~node_base() {}
};

struct node_value : node_base
{
	node_value(number value)
		: value_(value)
	{}

	virtual number evaluate() const override
	{
		return value_;
	}

private:
	number value_;
};

template <typename BinaryOperator>
struct node_binary_operator : node_base
{
	node_binary_operator(std::unique_ptr<node_base> left, std::unique_ptr<node_base> right)
		: left_(std::move(left)), right_(std::move(right))
	{}

	virtual number evaluate() const override
	{
		return BinaryOperator()(left_->evaluate(), right_->evaluate());
	}

private:
	std::unique_ptr<node_base> left_, right_;
};

struct power
{
	number operator () (number a, number b) const
	{
		return std::pow(a, b);
	}
};

typedef node_binary_operator<std::plus      <number>> node_add;
typedef node_binary_operator<std::minus     <number>> node_sub;
typedef node_binary_operator<std::multiplies<number>> node_mul;
typedef node_binary_operator<std::divides   <number>> node_div;
typedef node_binary_operator<power> node_pow;

#endif // AST_HPP

#ifndef MAKE_UNIQUE_HPP
#define MAKE_UNIQUE_HPP

#include <memory>
#include <utility>

template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
	return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

#endif // MAKE_UNIQUE_HPP

#ifndef PARSER_HPP
#define PARSER_HPP

//#include "ast.hpp"
//#include "make_unique.hpp"

template <char Symbol, typename NodeType>
struct operator_left;

template <char Symbol, typename NodeType>
struct operator_right;

template <typename... Operators>
struct operator_group;

template <typename... Groups>
struct operator_table;

template <typename LeftNextParser, typename RightNextParser, typename... Parsers>
struct operator_parser;

template <typename LeftNextParser, typename RightNextParser>
struct operator_parser<LeftNextParser, RightNextParser>
{
	static bool parse(char const*&, std::unique_ptr<node_base>&)
	{
		return false;
	}
};

template <typename LeftNextParser, typename RightNextParser, typename NextParser, char Symbol, typename NodeType, typename... Operators>
bool operator_parse_helper(char const*& string, std::unique_ptr<node_base>& result)
{
	if(*string == Symbol)
	{
		result = make_unique<NodeType>(std::move(result), NextParser::parse(++string));
		return true;
	}

	return operator_parser<LeftNextParser, RightNextParser, Operators...>::parse(string, result);
}

template <typename LeftNextParser, typename RightNextParser, char Symbol, typename NodeType, typename... Operators>
struct operator_parser<LeftNextParser, RightNextParser, operator_left<Symbol, NodeType>, Operators...>
{
	static bool parse(char const*& string, std::unique_ptr<node_base>& result)
	{
		return operator_parse_helper<LeftNextParser, RightNextParser, LeftNextParser, Symbol, NodeType, Operators...>(string, result);
	}
};

template <typename LeftNextParser, typename RightNextParser, char Symbol, typename NodeType, typename... Operators>
struct operator_parser<LeftNextParser, RightNextParser, operator_right<Symbol, NodeType>, Operators...>
{
	static bool parse(char const*& string, std::unique_ptr<node_base>& result)
	{
		return operator_parse_helper<LeftNextParser, RightNextParser, RightNextParser, Symbol, NodeType, Operators...>(string, result);
	}
};

template <typename Skipper, typename EndParser, typename NextParser, typename... Groups>
struct operator_group_parser;

template <typename Skipper, typename EndParser, typename NextParser, typename... GroupParsers, typename... Groups>
struct operator_group_parser<Skipper, EndParser, NextParser, operator_group<GroupParsers...>, Groups...>
{
	static std::unique_ptr<node_base> parse(char const*& string)
	{
		std::unique_ptr<node_base> result = NextParser::parse(string);

		do Skipper::skip(string);
		while(operator_parser<NextParser, operator_group_parser<Skipper, EndParser, NextParser, operator_group<GroupParsers...>>, GroupParsers...>::parse(string, result));

		return result;
	}
};

template <typename Skipper, typename EndParser, typename Table>
struct operator_table_parser
{
	static std::unique_ptr<node_base> parse(char const*& string)
	{
		return EndParser::parse(string);
	}
};

template <typename Skipper, typename EndParser, typename Group, typename... Groups>
struct operator_table_parser<Skipper, EndParser, operator_table<Group, Groups...>>
{
	static std::unique_ptr<node_base> parse(char const*& string)
	{
		return operator_group_parser<Skipper, EndParser, operator_table_parser<Skipper, EndParser, operator_table<Groups...>>, Group>::parse(string);
	}
};

template <typename Skipper, typename EndParser, typename Table>
std::unique_ptr<node_base> parse(char const*& string)
{
	return operator_table_parser<Skipper, EndParser, Table>::parse(string);
}

#endif // PARSER_HPP

#include <cctype>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <utility>

//#include "ast.hpp"
//#include "parser.hpp"

struct parse_error : std::runtime_error
{
	parse_error(std::string const& what)
		: runtime_error(what)
	{}
};

struct whitespace_skipper
{
	static void skip(char const*& string)
	{
		while(std::isspace(*string))
			++string;
	}
};

std::unique_ptr<node_base> parse_number(char const*& string)
{
	return make_unique<node_value>(std::strtod(string, const_cast<char**>(&string)));
}

std::unique_ptr<node_base> parse_binary_expression(char const*& string);

struct binary_operator_parser
{
	static std::unique_ptr<node_base> parse(char const*& string);
};

struct primary_expression_parser
{
	static std::unique_ptr<node_base> parse(char const*& string)
	{
		whitespace_skipper::skip(string);

		if(*string == '(')
		{
			auto ast = binary_operator_parser::parse(++string);
			whitespace_skipper::skip(string);

			if(*string != ')')
				throw parse_error("expected closing '(' here: " + std::string(string));

			++string;
			return ast;
		}

		return parse_number(string);
	}
};

typedef operator_table
<
	operator_group
	<
		operator_left<'+', node_add>,
		operator_left<'-', node_sub>
	>,
	operator_group
	<
		operator_left<'*', node_mul>,
		operator_left<'/', node_div>
	>,
	operator_group
	<
		operator_right<'^', node_pow>
	>
> operators;

std::unique_ptr<node_base> binary_operator_parser::parse(char const*& string)
{
	return ::parse<whitespace_skipper, primary_expression_parser, operators>(string);
}

std::unique_ptr<node_base> parse(char const* string)
{
	auto ast = binary_operator_parser::parse(string);

	if(*string)
		throw parse_error("unexpected character here: " + std::string(string));

	return ast;
}

int main()
{
	for(std::string line; std::getline(std::cin, line);)
		try
		{
			auto ast = parse(line.c_str());
			std::cout << ast->evaluate() << '\n';
		}

		catch(parse_error const& e)
		{
			std::cout << e.what() << '\n';
		}
}
