x=int(input()) y=int(input()) if(x>y): m=y*90+(x-y)60 else if(x<y): m=x90+(y-x)40 else: m=x90 print(m)