문제
Farmer John has opened a swimming pool for his cows, figuring it will help them relax and produce more milk.
To ensure safety, he hires
Unfortunately, Farmer John hired 1 more lifeguard than he has the funds to support. Given that he must fire exactly one lifeguard, what is the maximum amount of time that can still be covered by the shifts of the remaining lifeguards? An interval of time is covered if at least one lifeguard is present.
Problem credits: Brian Dean
입력
The first line of input contains
출력
Please write a single number, giving the maximum amount of time that can still be covered if Farmer John fires 1 lifeguard.
예제
3
5 9
1 4
3 7
7