import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int A = scan.nextInt(); int B = scan.nextInt(); int S = scan.nextInt(); scan.close(); int l1 = Math.abs(S - A); int l2 = Math.abs(S - B); if(S == 1) { if(A == 0) { System.out.println(2); }else { System.out.println(A); } System.exit(0); } if(l1 <= l2) { int ans = l1 + S; System.out.println(ans); }else { int ans = l2; if(A == 0) { ans += 2 + S - 1; System.out.println(ans); System.exit(0); } int t1 = l1 + A; int t2 = S + Math.abs(A - 1); ans += Math.min(t1, t2); System.out.println(ans); } } }