using System; class Program { static void Main() { var tmp = Console.ReadLine().Split(); int a = int.Parse(tmp[0]); int b = int.Parse(tmp[1]); int s = int.Parse(tmp[2]); int ans = 0; if (Math.Abs(a - s) <= Math.Abs(b - s)) { if (a < s) ans += s - a; ans += s; } else { if (a > b) { if (s > b) ans += 2 * a - b; else ans += 2 * a - s; } else { if (a == 0) ans++; if (s > b) ans += 2 * s - b; else ans += b; } } Console.WriteLine(ans); } }