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; if(a==0){ move+=1;a+=1;} if (a > s) { dis_a = a - s; } else { dis_a = s - a; } if (b > s) { dis_b = b - s; } else { dis_b = s - b; } if (dis_b >= dis_a) { move+=dis_a + s; }else{ move+=dis_b; if(a > s){ move+=dis_a + a; }else{ move+=s; } } System.out.println(move); } }