/*
import java.util.*;
class IntStack{
int ptr;
int[] stk;
int max;
public IntStack(int capacity) {
ptr=0;
max = capacity;
try {
stk = new int [max];
}catch(OutOfMemoryError e) {
max=0;
}
}
public class EmptyIntStackException extends RuntimeException{
public EmptyIntStackException(){
}
}
public class OverflowIntStackException extends RuntimeException{
public OverflowIntStackException() {
}
}
public int push(int x)throws OverflowIntStackException{
if(ptr>=max) {
throw new OverflowIntStackException();
}
return stk[ptr++]=x;
}
public int pop() {
if(ptr<=0) {
throw new EmptyIntStackException();
}
return stk[--ptr];
}
public int top() {
return ptr;
}
public int size() {
return max;
}
public boolean empty() {
if(ptr==0) {
return true;
}
return false;
}
}
public class Main {
public Main(){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
IntStack stack = new IntStack(n);
for(int i=0; i<n; i++) {
String s = scan.nextLine();
if(s.equals("top()")) {
stack.top();
}else if(s.equals("pop()")) {
stack.pop();
}else if(s.equals("size()")) {
stack.size();
}else if(s.equals("empty()")){
stack.empty();
}else{
int k = scan.nextInt();
stack.push(k);
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.util.*;
class IntStack{
int ptr;
int[] stk;
int max;
public IntStack(int capacity) {
ptr=0;
max = capacity;
try {
stk = new int [max];
}catch(OutOfMemoryError e) {
max=0;
}
}
public class EmptyIntStackException extends RuntimeException{
public EmptyIntStackException(){
}
}
public class OverflowIntStackException extends RuntimeException{
public OverflowIntStackException() {
}
}
public int push(int x)throws OverflowIntStackException{
if(ptr>=max) {
throw new OverflowIntStackException();
}
return stk[ptr++]=x;
}
public int pop() {
if(ptr<=0) {
throw new EmptyIntStackException();
}
return stk[--ptr];
}
public int top() {
return ptr;
}
public int size() {
return max;
}
public boolean empty() {
if(ptr==0) {
return true;
}
return false;
}
public void sum() {
int sum =0;
for(int i=0; i<ptr; i++) {
sum += stk[i];
}
System.out.println(sum);
}
}
public class Main {
public Main() {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
IntStack stk = new IntStack(n);
int[] arr = new int[n];
for(int i=0; i<n; i++) {
arr[i] = scan.nextInt();
if(arr[i]!=0) {
stk.push(arr[i]);
}else {
stk.pop();
}
}
stk.sum();
}
public static void main(String[] args) {
new Main();
}
}
*/
//import java.util.*;
//
//class IntStack{
// int ptr;
// int max;
// int[] stk;
// public IntStack(int capacity) {
// ptr = 0;
// max = capacity;
// try {
// stk = new int[max];
// }catch(OutOfMemoryError e) {
// max =0;
// }
// }
// public class EmptyIntStackException extends RuntimeException{
// public EmptyIntStackException(){
//
// }
// }
// public class OverflowIntStackException extends RuntimeException{
// public OverflowIntStackException() {
//
// }
// }
//
// public int push(int x)throws OverflowIntStackException{
// if(ptr>=max) {
// throw new OverflowIntStackException();
// }
// return stk[ptr++] =x;
// }
// public int pop() throws EmptyIntStackException{
// if(ptr<=0) {
// throw new EmptyIntStackException();
// }
// return stk[--ptr];
// }
//}
//
//public class Main{
// public Main() {
// Scanner scan = new Scanner(System.in);
// int n = scan.nextInt();
//
//
// }
// public static void main(String[] args) {
// new Main();
// }
//}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
String input = t.nextLine();
String []sp1 = input.split(" ");
int[] temp = new int[200];
int numTop=0;
char[] op = new char[2000];
int opTop=0;
for(int i=0; i<sp1.length; i++) {
if(sp1[i].equals("+") || sp1[i].equals("-") || sp1[i].equals("*")) {
if(opTop==0) {
op[opTop++] = sp1[i].charAt(0);
}
else if(op[opTop-1]=='*'){
if(sp1[i].charAt(0)=='+'||sp1[i].charAt(0)=='-') {
op[opTop-1] = sp1[i].charAt(0);
numTop--;
int b = temp[numTop];
temp[numTop] = 0;
numTop--;
int a = temp[numTop];
temp[numTop] = 0;
int c = a*b;
temp[numTop] = c;
numTop++;
}
}
else {
}
}else {
temp[numTop]=Integer.valueOf(sp1[i]);
numTop++;
}
}
if(op[opTop]=='+') {
temp[numTop-1]=temp[numTop-1]+temp[numTop-2];
numTop--;
}else {
temp[numTop-1]=temp[numTop-2]-temp[numTop-1];
numTop--;
}
for(int i=0; i<numTop; i++) {
System.out.println(temp[i]);
}
System.out.println(temp[numTop]);
}
}