package main import ( "fmt" "math" "sort" ) func MaxInt(x, y int) int { return int(math.Max(float64(x), float64(y))) } func MinInt(x, y int) int { return int(math.Min(float64(x), float64(y))) } func AbsInt(x int) int { return int(math.Abs(float64(x))) } func SortInt(d []int) { sort.Sort(sort.IntSlice(d)) } func resolve(A, B, S int) int { if A >= S { return A } if AbsInt(S-A) <= AbsInt(B-S) { return S - A + S } if A == 0 { return B - S + S + 1 } return B - S + S } func main() { var A, B, S int fmt.Scanf("%d %d %d\n", &A, &B, &S) fmt.Println(resolve(A, B, S)) }