a,b,c,d = map(int,input().split()) red = [i for i in range(a,b+1)] blk = [i for i in range(c,d+1)] array=[] for i in red: tmp=[i] for j in blk: tmp.append(j) if not tmp in array and tmp[0]!=tmp[1]: array.append(tmp) tmp=[i] print(len(array))