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 t1, t2; if(A == 0) { t1 = S + S; if(S - B > 0) { t2 = S - B + S + 1; }else { t2 = B - S + S + 1; } System.out.println(Math.min(t1, t2)); System.exit(0); } if(S - A > 0) { t1 = S - A + S ; }else { t1 = A - S + S ; } if(S - B > 0) { t2 = S - B; if(S - A > 0) { t2 += S - A + A; }else { t2 += A - S + A ; } }else { t2 = B - S; if(S - A > 0) { t2 += S - A + A; }else { t2 += A - S + A ; } } int ans = Math.min(t1, t2); System.out.println(ans); } }