import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int s = sc.nextInt(); int mva = Math.abs(a-s); int mvb = Math.abs(b-s); int sum = 0; if(mva <= mvb){ // aの方が近い sum += mva + s; }else{ // bの方が近い if(a == 0 && mva != mvb){ a++; sum++; } if(mva > (s-1)){ sum += mvb + (s-1) + a; }else{ sum += mvb + mva + a; } } System.out.println(sum); } }