a,b,c,d = map(int,input().split()) count_num = 0 for i in range(a,b+1): for j in range(c,d+1): if i == j: count_num -=1 count_num += 1 print(count_num)