import std.algorithm, std.array, std.container, std.range; import std.string, std.conv; import std.math, std.bigint, std.bitmanip, std.random; import std.stdio, std.typecons; void main() { auto rd = readln.split.map!(to!int); auto a = rd[0], b = rd[1], s = rd[2]; if (s == 1) { if (a == 0) writeln(2); else writeln(a); } else if ((s - a).abs <= (s - b).abs) { writeln((s - a).abs + s); } else { if (s > a && s - a <= s - 1) writeln((s - b).abs + s); else if (a == 0) writeln((s - b).abs + s - 1 + 2); else writeln((s - b).abs + s - 1 + a); } }