#include <iostream>
#include <cstring>

using namespace std;

template<class T>
class Stack
{
private:
    T *s;
    int N;

public:
    Stack(int maxn)
    {
        s = new T[maxn];
        N = 0;
    }
    int empty()const
    {
        return N == 0;
    }
    void push(T k)
    {
        s[N++] = k;
    }
    T pop()
    {
        return s[--N];
    }
};

int main()
{
    //postfix evaluation
    const char *a = "3 4 5*+";
    int N = strlen(a);

    Stack<int>save(N);

    for (int i = 0; i < N; i++)
    {
        if (a[i]=='+')
            save.push(save.pop() + save.pop());

        if (a[i]=='*')
            save.push(save.pop() * save.pop());

        if (a[i] >= '0' && a[i] <= '9')
        {
            save.push(0);
            while (a[i] >= '0' && a[i] <= '9')
                save.push(10 * save.pop() + a[i++] - '0');
            i--;
        }
    }

    cout << save.pop() << "  " << endl;

    return 0;
}
