Problem: You are enthusiastically participating in Virtual Boot Camp-14 and want to seriously learn programming. To be a good programmer you not only need to solve a problem, but also need to solve it as quickly as possible. 

You are participating in this "Week02 Contest" and want to win it. You are sure that you will be able to solve all the questions in this contest, but to become Rank 1, you need to solve every problem in least amount of time with least number of wrong attempts.

The person solving maximum # of problems with least amount of time penalty wins the contest.So before solving any harder problem in the contest, you want to be prepared with a program which calculates time penalty for you. 

You know that you start the contest at exactly 1/7/14 00:00 and end the contest at D/7/14 HH:MM with W #number of wrong attempts. [One wrong attempt adds 20 minutes to your time penalty] 

You have to output the final time penalty.

Note: For simplicity we assume we have only one problem to solve during the contest

INPUT FORMAT:

Line 1: 4 Integers D H M W

CONSTRAINTS:

1 ≤ D ≤ 5

0 ≤ H ≤ 23

0 ≤ M ≤ 59

0 ≤ W ≤ 10^8

OUTPUT FORMAT:

Line 1: Time Penalty in Minutes

SAMPLE INPUT
5 0 0 100000000

SAMPLE OUTPUT
2000005760

Solution (in PYTHON):

Solution:
d = map(int, raw_input().split())
days = d[0] - 1
hours = d[1]
minutes = d[2]
w_ans = d[3]
total = ((days * 24) * 60) + (hours * 60) + minutes + (20 * w_ans)
print total