a,b,c=map(int,input().split()) n=sorted([a,b,c]) if a==n[1] or c==n[1]: cost1=abs(a-c) cost2=(n[2]-n[1])+1 print(min(cost1,cost2)) else: print(0)