def min(a,b,c):
    if a<b and a<c:
        return a
    elif b<c:
        return b
    else:
        return c


def calc(x):
    try:
        a=x.index("+")
    except:
        a=300
    try:
        b=x.index("-")
    except:
        b=300
    try:
        c=x.index("*")
    except:
        c=300

    ind=min(a,b,c)

    if ind==300:
        return x[0]
    
    if x[ind]=="+":
        x.insert(ind-2,int(x[ind-2])+int(x[ind-1]))
    elif x[ind]=="-":
        x.insert(ind-2,int(x[ind-2])-int(x[ind-1]))
    else:
        x.insert(ind-2,int(x[ind-2])*int(x[ind-1]))
    x.pop(ind-1)
    x.pop(ind-1)
    x.pop(ind-1)
    return calc(x)


operas=input().split(" ")
print (calc(operas)) def min(a,b,c):
    if a<b and a<c:
        return a
    elif b<c:
        return b
    else:
        return c min if a<b and a<c:
        return a
    elif b<c:
        return b
    else:
        return c a<b and a<c a<b a b a<c a c return a a elif b<c:
        return b
     b<c b c return b b return c c a a b b c c def calc(x):
    try:
        a=x.index("+")
    except:
        a=300
    try:
        b=x.index("-")
    except:
        b=300
    try:
        c=x.index("*")
    except:
        c=300

    ind=min(a,b,c)

    if ind==300:
        return x[0]
    
    if x[ind]=="+":
        x.insert(ind-2,int(x[ind-2])+int(x[ind-1]))
    elif x[ind]=="-":
        x.insert(ind-2,int(x[ind-2])-int(x[ind-1]))
    else:
        x.insert(ind-2,int(x[ind-2])*int(x[ind-1]))
    x.pop(ind-1)
    x.pop(ind-1)
    x.pop(ind-1)
    return calc(x) calc try:
        a=x.index("+")
    except:
        a=300
     except:
        a=300
     a=300 a 300 a=x.index("+") a x.index("+") x.index x index "+" try:
        b=x.index("-")
    except:
        b=300
     except:
        b=300
     b=300 b 300 b=x.index("-") b x.index("-") x.index x index "-" try:
        c=x.index("*")
    except:
        c=300

     except:
        c=300

     c=300 c 300 c=x.index("*") c x.index("*") x.index x index "*" ind=min(a,b,c) ind min(a,b,c) min a b c if ind==300:
        return x[0]
    
     ind==300 ind 300 return x[0] x[0] x 0 if x[ind]=="+":
        x.insert(ind-2,int(x[ind-2])+int(x[ind-1]))
    elif x[ind]=="-":
        x.insert(ind-2,int(x[ind-2])-int(x[ind-1]))
    else:
        x.insert(ind-2,int(x[ind-2])*int(x[ind-1]))
     x[ind]=="+" x[ind] x ind "+" x.insert(ind-2,int(x[ind-2])+int(x[ind-1])) x.insert x insert ind-2 ind 2 int(x[ind-2])+int(x[ind-1]) int(x[ind-2]) int x[ind-2] x ind-2 ind 2 int(x[ind-1]) int x[ind-1] x ind-1 ind 1 elif x[ind]=="-":
        x.insert(ind-2,int(x[ind-2])-int(x[ind-1]))
     x[ind]=="-" x[ind] x ind "-" x.insert(ind-2,int(x[ind-2])-int(x[ind-1])) x.insert x insert ind-2 ind 2 int(x[ind-2])-int(x[ind-1]) int(x[ind-2]) int x[ind-2] x ind-2 ind 2 int(x[ind-1]) int x[ind-1] x ind-1 ind 1 x.insert(ind-2,int(x[ind-2])*int(x[ind-1])) x.insert x insert ind-2 ind 2 int(x[ind-2])*int(x[ind-1]) int(x[ind-2]) int x[ind-2] x ind-2 ind 2 int(x[ind-1]) int x[ind-1] x ind-1 ind 1 x.pop(ind-1) x.pop x pop ind-1 ind 1 x.pop(ind-1) x.pop x pop ind-1 ind 1 x.pop(ind-1) x.pop x pop ind-1 ind 1 return calc(x) calc(x) calc x x x operas=input().split(" ") operas input().split(" ") ().split () input split " " print (calc(operas)) print calc(operas) calc operas def calc(x):
    try:
        a=x.index("+")
    except:
        a=300
    try:
        b=x.index("-")
    except:
        b=300
    try:
        c=x.index("*")
    except:
        c=300

    ind=min(a,b,c)

    if ind==300:
        return x[0]
    
    if x[ind]=="+":
        x.insert(ind-2,int(x[ind-2])+int(x[ind-1]))
    elif x[ind]=="-":
        x.insert(ind-2,int(x[ind-2])-int(x[ind-1]))
    else:
        x.insert(ind-2,int(x[ind-2])*int(x[ind-1]))
    x.pop(ind-1)
    x.pop(ind-1)
    x.pop(ind-1)
    return calc(x) def calc(x):
    try:
        a=x.index("+")
    except:
        a=300
    try:
        b=x.index("-")
    except:
        b=300
    try:
        c=x.index("*")
    except:
        c=300

    ind=min(a,b,c)

    if ind==300:
        return x[0]
    
    if x[ind]=="+":
        x.insert(ind-2,int(x[ind-2])+int(x[ind-1]))
    elif x[ind]=="-":
        x.insert(ind-2,int(x[ind-2])-int(x[ind-1]))
    else:
        x.insert(ind-2,int(x[ind-2])*int(x[ind-1]))
    x.pop(ind-1)
    x.pop(ind-1)
    x.pop(ind-1)
    return calc(x) calc def min(a,b,c):
    if a<b and a<c:
        return a
    elif b<c:
        return b
    else:
        return c def min(a,b,c):
    if a<b and a<c:
        return a
    elif b<c:
        return b
    else:
        return c min operas=input().split(" ") input().split(" ") operas
def min(a,b,c):
    if a<b and a<c:
        return a
    elif b<c:
        return b
    else:
        return c


def calc(x):
    try:
        a=x.index("+")
    except:
        a=300
    try:
        b=x.index("-")
    except:
        b=300
    try:
        c=x.index("*")
    except:
        c=300

    ind=min(a,b,c)

    if ind==300:
        return x[0]
    
    if x[ind]=="+":
        x.insert(ind-2,int(x[ind-2])+int(x[ind-1]))
    elif x[ind]=="-":
        x.insert(ind-2,int(x[ind-2])-int(x[ind-1]))
    else:
        x.insert(ind-2,int(x[ind-2])*int(x[ind-1]))
    x.pop(ind-1)
    x.pop(ind-1)
    x.pop(ind-1)
    return calc(x)


operas=input().split(" ")
print (calc(operas))