import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] arg) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    sc.close();
    System.out.println(compute(line));
  }

  private static int compute(String line) {
    String[] elements = line.split(" ");
    LinkedList<String> stack = new LinkedList<>();
    for (String element : elements) {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    }
    return Integer.valueOf(stack.poll());
  }
} import java.util.LinkedList; LinkedList java.util import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] arg) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    sc.close();
    System.out.println(compute(line));
  }

  private static int compute(String line) {
    String[] elements = line.split(" ");
    LinkedList<String> stack = new LinkedList<>();
    for (String element : elements) {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    }
    return Integer.valueOf(stack.poll());
  }
} Main public static void main(String[] arg) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    sc.close();
    System.out.println(compute(line));
  } main {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    sc.close();
    System.out.println(compute(line));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc sc.close() sc.close sc System.out.println(compute(line)) System.out.println System.out System System.out compute(line) compute line String[] arg arg private static int compute(String line) {
    String[] elements = line.split(" ");
    LinkedList<String> stack = new LinkedList<>();
    for (String element : elements) {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    }
    return Integer.valueOf(stack.poll());
  } compute {
    String[] elements = line.split(" ");
    LinkedList<String> stack = new LinkedList<>();
    for (String element : elements) {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    }
    return Integer.valueOf(stack.poll());
  } String[] elements = line.split(" "); elements line.split(" ") line.split line " " LinkedList<String> stack = new LinkedList<>(); stack new LinkedList<>() for (String element : elements) {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    } String element elements {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    } {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    } if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      } element.matches("[0-9]+") element.matches element "[0-9]+" {
        stack.push(element);
      } stack.push(element) stack.push stack element if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      } element.equals("+") element.equals element "+" {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } int a = Integer.valueOf(stack.poll()); a Integer.valueOf(stack.poll()) Integer.valueOf Integer stack.poll() stack.poll stack int b = Integer.valueOf(stack.poll()); b Integer.valueOf(stack.poll()) Integer.valueOf Integer stack.poll() stack.poll stack stack.push(String.valueOf(b + a)) stack.push stack String.valueOf(b + a) String.valueOf String b + a b a if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      } element.equals("-") element.equals element "-" {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } int a = Integer.valueOf(stack.poll()); a Integer.valueOf(stack.poll()) Integer.valueOf Integer stack.poll() stack.poll stack int b = Integer.valueOf(stack.poll()); b Integer.valueOf(stack.poll()) Integer.valueOf Integer stack.poll() stack.poll stack stack.push(String.valueOf(b - a)) stack.push stack String.valueOf(b - a) String.valueOf String b - a b a if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      } element.equals("*") element.equals element "*" {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      } int a = Integer.valueOf(stack.poll()); a Integer.valueOf(stack.poll()) Integer.valueOf Integer stack.poll() stack.poll stack int b = Integer.valueOf(stack.poll()); b Integer.valueOf(stack.poll()) Integer.valueOf Integer stack.poll() stack.poll stack stack.push(String.valueOf(b * a)) stack.push stack String.valueOf(b * a) String.valueOf String b * a b a return Integer.valueOf(stack.poll()); Integer.valueOf(stack.poll()) Integer.valueOf Integer stack.poll() stack.poll stack String line line public class Main {
  public static void main(String[] arg) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    sc.close();
    System.out.println(compute(line));
  }

  private static int compute(String line) {
    String[] elements = line.split(" ");
    LinkedList<String> stack = new LinkedList<>();
    for (String element : elements) {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    }
    return Integer.valueOf(stack.poll());
  }
} public class Main {
  public static void main(String[] arg) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    sc.close();
    System.out.println(compute(line));
  }

  private static int compute(String line) {
    String[] elements = line.split(" ");
    LinkedList<String> stack = new LinkedList<>();
    for (String element : elements) {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    }
    return Integer.valueOf(stack.poll());
  }
} Main
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] arg) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    sc.close();
    System.out.println(compute(line));
  }

  private static int compute(String line) {
    String[] elements = line.split(" ");
    LinkedList<String> stack = new LinkedList<>();
    for (String element : elements) {
      if (element.matches("[0-9]+")) {
        stack.push(element);
      } else if (element.equals("+")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b + a));
      } else if (element.equals("-")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b - a));
      } else if (element.equals("*")) {
        int a = Integer.valueOf(stack.poll());
        int b = Integer.valueOf(stack.poll());
        stack.push(String.valueOf(b * a));
      }
    }
    return Integer.valueOf(stack.poll());
  }
}
