import java.util.Scanner;


class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		
		ReversePolishNotation(scanner);
		
		scanner.close();
	}
	
	public static enum Operator
	{
		plus(43),
		times(42),
		minus(45);
		
		private final int mark;
		
		private Operator(final int mark) {
			this.mark = mark;
		}
		
		public int getInt(){
			return this.mark;
		}
	}
	public static Operator getMark(final int id) {
		Operator[] marks = Operator.values();
		for (Operator type : marks) {
			if (type.getInt() == id) {
				return type;
			}
		}
		return null;
	}

	public static void ReversePolishNotation(Scanner scanner ){ // N個の要素を含む0-オリジンの配列A
		String num;
		int sub;
		int array_num[] = new int[100];
		int count = 0;
		int count_num = 0;
		int i;
		byte[] oper = new byte[200];
		
		
		while( scanner.hasNext() ){
			num = scanner.next();
			try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		
			sub = (int)oper[0];
			
			if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			}
		
		}
		System.out.println(array_num[0]);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		
		ReversePolishNotation(scanner);
		
		scanner.close();
	}
	
	public static enum Operator
	{
		plus(43),
		times(42),
		minus(45);
		
		private final int mark;
		
		private Operator(final int mark) {
			this.mark = mark;
		}
		
		public int getInt(){
			return this.mark;
		}
	}
	public static Operator getMark(final int id) {
		Operator[] marks = Operator.values();
		for (Operator type : marks) {
			if (type.getInt() == id) {
				return type;
			}
		}
		return null;
	}

	public static void ReversePolishNotation(Scanner scanner ){ // N個の要素を含む0-オリジンの配列A
		String num;
		int sub;
		int array_num[] = new int[100];
		int count = 0;
		int count_num = 0;
		int i;
		byte[] oper = new byte[200];
		
		
		while( scanner.hasNext() ){
			num = scanner.next();
			try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		
			sub = (int)oper[0];
			
			if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			}
		
		}
		System.out.println(array_num[0]);
	}
} Main public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		
		ReversePolishNotation(scanner);
		
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		
		ReversePolishNotation(scanner);
		
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) ReversePolishNotation(scanner) ReversePolishNotation scanner scanner.close() scanner.close scanner String args[] args public static Operator getMark(final int id) {
		Operator[] marks = Operator.values();
		for (Operator type : marks) {
			if (type.getInt() == id) {
				return type;
			}
		}
		return null;
	} getMark {
		Operator[] marks = Operator.values();
		for (Operator type : marks) {
			if (type.getInt() == id) {
				return type;
			}
		}
		return null;
	} Operator[] marks = Operator.values(); marks Operator.values() Operator.values Operator for (Operator type : marks) {
			if (type.getInt() == id) {
				return type;
			}
		} Operator type marks {
			if (type.getInt() == id) {
				return type;
			}
		} {
			if (type.getInt() == id) {
				return type;
			}
		} if (type.getInt() == id) {
				return type;
			} type.getInt() == id type.getInt() type.getInt type id {
				return type;
			} return type; type return null; null final int id id public static void ReversePolishNotation(Scanner scanner ){ // N個の要素を含む0-オリジンの配列A
		String num;
		int sub;
		int array_num[] = new int[100];
		int count = 0;
		int count_num = 0;
		int i;
		byte[] oper = new byte[200];
		
		
		while( scanner.hasNext() ){
			num = scanner.next();
			try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		
			sub = (int)oper[0];
			
			if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			}
		
		}
		System.out.println(array_num[0]);
	} ReversePolishNotation { // N個の要素を含む0-オリジンの配列A
		String num;
		int sub;
		int array_num[] = new int[100];
		int count = 0;
		int count_num = 0;
		int i;
		byte[] oper = new byte[200];
		
		
		while( scanner.hasNext() ){
			num = scanner.next();
			try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		
			sub = (int)oper[0];
			
			if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			}
		
		}
		System.out.println(array_num[0]);
	} String num; num int sub; sub int array_num[] = new int[100]; array_num new int[100] 100 int count = 0; count 0 int count_num = 0; count_num 0 int i; i byte[] oper = new byte[200]; oper new byte[200] 200 while( scanner.hasNext() ){
			num = scanner.next();
			try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		
			sub = (int)oper[0];
			
			if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			}
		
		} scanner.hasNext() scanner.hasNext scanner {
			num = scanner.next();
			try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		
			sub = (int)oper[0];
			
			if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			}
		
		} num = scanner.next() num scanner.next() scanner.next scanner try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} Exception e {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				oper = num.getBytes("US-ASCII");
			} oper = num.getBytes("US-ASCII") oper num.getBytes("US-ASCII") num.getBytes num "US-ASCII" sub = (int)oper[0] sub (int)oper[0] oper 0 if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			} sub < 42 || sub > 45 sub < 42 sub 42 sub > 45 sub 45 {
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			} array_num[count_num] = Integer.parseInt(num) array_num[count_num] array_num count_num Integer.parseInt(num) Integer.parseInt Integer num count_num ++ count_num {
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			} count_num -= 2 count_num 2 if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				} count_num >= 0 count_num 0 {
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				} switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					} getMark(sub) getMark sub case plus: plus case plus: array_num[count_num] = array_num[count_num] + array_num[count_num + 1] array_num[count_num] array_num count_num array_num[count_num] + array_num[count_num + 1] array_num[count_num] array_num count_num array_num[count_num + 1] array_num count_num + 1 count_num 1 count_num ++ count_num break; case times: times case times: array_num[count_num] = array_num[count_num] * array_num[count_num + 1] array_num[count_num] array_num count_num array_num[count_num] * array_num[count_num + 1] array_num[count_num] array_num count_num array_num[count_num + 1] array_num count_num + 1 count_num 1 count_num ++ count_num break; case minus: minus case minus: array_num[count_num] = array_num[count_num] - array_num[count_num + 1] array_num[count_num] array_num count_num array_num[count_num] - array_num[count_num + 1] array_num[count_num] array_num count_num array_num[count_num + 1] array_num count_num + 1 count_num 1 count_num ++ count_num {
					break;
				} break; count ++ count System.out.println(array_num[0]) System.out.println System.out System System.out array_num[0] array_num 0 Scanner scanner scanner public static enum Operator
	{
		plus(43),
		times(42),
		minus(45);
		
		private final int mark;
		
		private Operator(final int mark) {
			this.mark = mark;
		}
		
		public int getInt(){
			return this.mark;
		}
	} Operator plus(43) plus times(42) times minus(45) minus private final int mark; mark private Operator(final int mark) {
			this.mark = mark;
		} Operator {
			this.mark = mark;
		} this.mark = mark this.mark this this.mark mark final int mark mark public int getInt(){
			return this.mark;
		} getInt {
			return this.mark;
		} return this.mark; this.mark this this.mark import java.util.Scanner;


class Mai import java.util.Scanner;


class Main {
	public static void main(String args[]) {
		Scanner scanne
import java.util.Scanner;


class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		
		ReversePolishNotation(scanner);
		
		scanner.close();
	}
	
	public static enum Operator
	{
		plus(43),
		times(42),
		minus(45);
		
		private final int mark;
		
		private Operator(final int mark) {
			this.mark = mark;
		}
		
		public int getInt(){
			return this.mark;
		}
	}
	public static Operator getMark(final int id) {
		Operator[] marks = Operator.values();
		for (Operator type : marks) {
			if (type.getInt() == id) {
				return type;
			}
		}
		return null;
	}

	public static void ReversePolishNotation(Scanner scanner ){ // N個の要素を含む0-オリジンの配列A
		String num;
		int sub;
		int array_num[] = new int[100];
		int count = 0;
		int count_num = 0;
		int i;
		byte[] oper = new byte[200];
		
		
		while( scanner.hasNext() ){
			num = scanner.next();
			try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		
			sub = (int)oper[0];
			
			if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			}
		
		}
		System.out.println(array_num[0]);
	}
}
