THE QUESTION
Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.
A long straight wall needs to be painted, and two painters have been assigned the task. The first painter paints the interval between x=a and x=b. For example, if a=3 and b=5, then the painter paints an interval of length 2. The other painter paints the interval from x=c to x=d, which may possibly overlap with part or all of Farmer John's interval. Please determine the total length of fence that is now covered with paint. The first line of the input contains the integers a and b, separated by a space (a<b). The second line contains integers c and d, separated by a space (c<d). The values of a, b, c, and d all lie in the range 0…100, inclusive. Please output a single line containing the total length of the fence covered with paint. SAMPLE INPUT: 7 10 4 8 SAMPLE OUTPUT: 6 Input Case 1: 52 76 23 52 Case 2: 10 72 33 72