a, b, c = [ int(v) for v in input().split() ] if a > c: a, c = c, a print( min(b-c, c-a) )