Having dropped out of school because of chemistry, Luka got a job driving trucks. One evening he parked his three trucks in a rest area which charges for parking in an unusual way – they give a discount on quantity.
When only one truck is parked, the driver pays
Given the numbers
Input Specification
The first line contains three integers
Each of the following three lines contains two integers. These are the arrival and departure times
(in minutes) of one of Luka's trucks. The arrival time will always be earlier than the departure time. All
time indices will be between
Output Specification
Output the overall cost of Luka's parking his three trucks.
Sample Input 1
5 3 1
1 6
3 5
2 8
Sample Output 1
33
Sample Input 2
10 8 6
15 30
25 50
70 80
Sample Output 2
480
Comments