import java.util.Scanner; public class No_126 { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int s = sc.nextInt(); int move = 0; sc.close(); int dis_a = 0; int dis_b = 0; dis_a = Math.abs(a - s); dis_b = Math.abs(b - s); if (s == 1 || dis_b >= dis_a) { move += dis_a + s; } else if (a == 0) { move += dis_b + s + 1; } else { move += Math.min(dis_b+s+a-1, dis_b+a+dis_a); } System.out.println(move); } }