a,b,c = map(int,input().split()) ans = 0 if a <= b <= c: print(0) exit() if a ==c: print(abs(a-b)+1) exit() if a > c: a,c = c,a if b < a: ans = a-b+1 else: ans = b-c+1 ans = min(ans,c-a) print(ans)