using static System.Math; using System; public class Hello { public static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var a = int.Parse(line[0]); var b = int.Parse(line[1]); var s = int.Parse(line[2]); var ans = getAns(a, b, s); Console.WriteLine(ans); } public static int getAns (int a, int b, int s) { if (s == 1 && a == 0) return 2; if (s == 1 && a > 0) return a; var a1 = Abs(a - s); var b1 = Abs(b - s); if (a1 <= b1) return a1 + s; else return b1 + s + Abs(a - 1); } }