import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    }
  }
}

class Stack {
  int[] stack;
  int ite;

  public Stack(int capacity) {
    stack = new int[capacity];
    ite = 0;
  }

  public void initialize() {
    ite = 0;
  }

  public int getIte() {
    return ite;
  }

  public boolean isEmpty() {
    return ite == 0;
  }

  public boolean isFull() {
    return ite >= stack.length-1;
  }

  public  boolean push(int x) {
    if(isFull()) return false;

    stack[++ite] = x;
    return true;
  }

  public int pop() {
    if(isEmpty()) return 0;

    return stack[ite--];

  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    }
  }
} Main public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    }
  } main {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    }
  } try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    } {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String[] line = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int buf = 0; buf 0 Stack stack = new Stack(line.length); stack new Stack(line.length) for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      } String s line {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      } {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      } switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        } s case "+" : "+" case "+" : buf += stack.pop() buf stack.pop() stack.pop stack buf += stack.pop() buf stack.pop() stack.pop stack stack.push(buf) stack.push stack buf buf = 0 buf 0 break; case "-" : "-" case "-" : buf -= stack.pop() buf stack.pop() stack.pop stack buf += stack.pop() buf stack.pop() stack.pop stack stack.push(buf) stack.push stack buf buf = 0 buf 0 break; case "*" : "*" case "*" : buf  = stack.pop() buf stack.pop() stack.pop stack buf *= stack.pop() buf stack.pop() stack.pop stack stack.push(buf) stack.push stack buf buf = 0 buf 0 break; default : default : stack.push(Integer.parseInt(s)) stack.push stack Integer.parseInt(s) Integer.parseInt Integer s break; while(!stack.isEmpty())
        buf += stack.pop(); !stack.isEmpty() stack.isEmpty() stack.isEmpty stack buf += stack.pop() buf stack.pop() stack.pop stack System.out.println(buf) System.out.println System.out System System.out buf String[] args args class Stack {
  int[] stack;
  int ite;

  public Stack(int capacity) {
    stack = new int[capacity];
    ite = 0;
  }

  public void initialize() {
    ite = 0;
  }

  public int getIte() {
    return ite;
  }

  public boolean isEmpty() {
    return ite == 0;
  }

  public boolean isFull() {
    return ite >= stack.length-1;
  }

  public  boolean push(int x) {
    if(isFull()) return false;

    stack[++ite] = x;
    return true;
  }

  public int pop() {
    if(isEmpty()) return 0;

    return stack[ite--];

  }
} Stack int[] stack; stack int ite; ite public Stack(int capacity) {
    stack = new int[capacity];
    ite = 0;
  } Stack {
    stack = new int[capacity];
    ite = 0;
  } stack = new int[capacity] stack new int[capacity] capacity ite = 0 ite 0 int capacity capacity public void initialize() {
    ite = 0;
  } initialize {
    ite = 0;
  } ite = 0 ite 0 public int getIte() {
    return ite;
  } getIte {
    return ite;
  } return ite; ite public boolean isEmpty() {
    return ite == 0;
  } isEmpty {
    return ite == 0;
  } return ite == 0; ite == 0 ite 0 public boolean isFull() {
    return ite >= stack.length-1;
  } isFull {
    return ite >= stack.length-1;
  } return ite >= stack.length-1; ite >= stack.length-1 ite stack.length-1 stack.length stack stack.length 1 public  boolean push(int x) {
    if(isFull()) return false;

    stack[++ite] = x;
    return true;
  } push {
    if(isFull()) return false;

    stack[++ite] = x;
    return true;
  } if(isFull()) return false; isFull() isFull return false; false stack[++ite] = x stack[++ite] stack ++ite ite x return true; true int x x public int pop() {
    if(isEmpty()) return 0;

    return stack[ite--];

  } pop {
    if(isEmpty()) return 0;

    return stack[ite--];

  } if(isEmpty()) return 0; isEmpty() isEmpty return 0; 0 return stack[ite--]; stack[ite--] stack ite-- ite public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    }
  }
} public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    }
  }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    }
  }
}

class Stack {
  int[] stack;
  int ite;

  public Stack(int capacity) {
    stack = new int[capacity];
    ite = 0;
  }

  public void initialize() {
    ite = 0;
  }

  public int getIte() {
    return ite;
  }

  public boolean isEmpty() {
    return ite == 0;
  }

  public boolean isFull() {
    return ite >= stack.length-1;
  }

  public  boolean push(int x) {
    if(isFull()) return false;

    stack[++ite] = x;
    return true;
  }

  public int pop() {
    if(isEmpty()) return 0;

    return stack[ite--];

  }
}
