시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 341 143 138 50.000%

문제

오랜만에 휴일은 가진 연정이는 낡은 울타리를 칠하기로 결심했다.

그러나 넓은 울타리를 하루만에 모두 칠하지 못 할것을 깨닳은 연정이는 두 개의 구간을 임의로 지정한 후 겹치는 최대 영역만큼만 칠하기로 결정했다.

임의로 지정한 두 구간이 주어질 때 연정이가 칠할 최대 울타리 수를 출력하시오. 

입력

a , b , c , d 모두 0 ~ 100 사이이며

첫 번째 줄에는 임의로 지정한 수 a , b 가 주어진다. ( a < b )

두 번째 줄에는 임의로 지정한 수 c , d 가 주어진다. ( c < d )

출력

연정이가 칠할 최대 울타리 수를 출력하시오.

예제 입력 1

7 10
4 8

예제 출력 1

6

힌트

(7 , 10) , (4 , 8) 이 주어진다면 4 ~ 10 영역이 가장 최대로 겹치는 구간이므로 총 6개의 울타리를 칠할 수 있다.

W3sicHJvYmxlbV9pZCI6IjExOTcwIiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHVkMzk4XHVjNzc4XHVkMzA1IiwiZGVzY3JpcHRpb24iOiI8cD5cdWM2MjRcdWI3OWNcdWI5Y2NcdWM1ZDAgXHVkNzM0XHVjNzdjXHVjNzQwIFx1YWMwMFx1YzljNCBcdWM1ZjBcdWM4MTVcdWM3NzRcdWIyOTQgXHViMGExXHVjNzQwIFx1YzZiOFx1ZDBjMFx1YjlhY1x1Yjk3YyBcdWNlNjBcdWQ1NThcdWFlMzBcdWI4NWMgXHVhY2IwXHVjMmVjXHVkNTg4XHViMmU0LjxcL3A+XHJcblxyXG48cD5cdWFkZjhcdWI3ZWNcdWIwOTggXHViMTEzXHVjNzQwIFx1YzZiOFx1ZDBjMFx1YjlhY1x1Yjk3YyBcdWQ1NThcdWI4ZThcdWI5Y2NcdWM1ZDAgXHViYWE4XHViNDUwIFx1Y2U2MFx1ZDU1OFx1YzljMCBcdWJhYmIgXHVkNTYwXHVhYzgzXHVjNzQ0IFx1YW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