a,b,c,d,e=list(map(int,input())) if e-d>0 : print(a-b+(e-d)*c) else : print(a-b)