# coding: utf-8 # Your code here! A,B,C=map(int,input().split()) print(min(abs(A-C),B-max(A,C)))