#include <stdio.h>
#include <math.h>
#include <string.h>

double nextval() {
	static double val;
	scanf("%lf", &val);
	return val;
}

char nextop() {
	static char op[2] = "";
	if(scanf("%1s", op) < 1) // 입력의 끝?
		return '\0';
	return *op; // 연산자 리턴
}

double do_calculate(double val1, char op, double val2) {
	switch(op) {
		case '+':
			return val1 + val2;
		case '-':
			return val1 - val2;
		case '*':
			return val1 * val2;
		case '/':
			return val1 / val2;
		case '^':
			return pow(val1, val2);
		case '<':
			return (double)((int)val1 * (1 << (int)val2));
		case '>':
			return (double)((int)val1 / (1 << (int)val2));
		case '&':
			return (double)((int)val1 & (int)val2);
		case '|':
			return (double)((int)val1 | (int)val2);
	}
}

int check_later_is_prior(char op_first, char op_later) {
	const char *order = "^*+<&|";
	
	if(op_first == '-') op_first = '+';
	else if(op_first == '/') op_first = '*';
	else if(op_first == '>') op_first = '<';
	
	if(op_later == '-') op_later = '+';
	else if(op_later == '/') op_later = '*';
	else if(op_later == '>') op_later = '<';
	
	return strchr(order, op_later) < strchr(order, op_first);
}

double calculate(double val1, double op, double val2, char op2) {
	if(op2 == '\0') { // 연산이 더 없는 경우
		return do_calculate(val1, op, val2);
	} else {
		double nval = nextval();
		char nop = nextop();
		
		if(check_later_is_prior(op, op2)) // 뒤의 연산을 더 먼저 해야하는 경우
			return do_calculate(val1, op, calculate(val2, op2, nval, nop));
		else
			return calculate(do_calculate(val1, op, val2), op2, nval, nop);
	}
}

int main() {
	double val1 = nextval();
	char op1 = nextop();
	double val2 = nextval();
	char op2 = nextop();
	printf("Result: %g\n", calculate(val1, op1, val2, op2));
	return 0;
}