문제
Several seasons of hot summers and cold winters have taken their toll on Farmer John's fence, and he decides it is time to repaint it, along with the help of his favorite cow, Bessie. Unfortunately, while Bessie is actually remarkably proficient at painting, she is not as good at understanding Farmer John's instructions.
If we regard the fence as a one-dimensional number line, Farmer John paints the interval between
Problem credits: Brian Dean
입력
The first line of the input contains the integers
The second line contains integers
The values of
출력
Please output a single line containing the total length of the fence covered with paint.
예제1
7 10
4 8
6
Here, 6 total units of fence are covered with paint, from