a,b,c = map(int,input().split()) print(min(abs(a-c), b - a + 1, b - c + 1))