package no126; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); System.out.println(solve(a,b,c)); } public static int solve(int a,int b,int s) { int la = Math.abs(a-s); int lb = Math.abs(b-s); int ans = 0; if (a == 0) { if (la <= lb) { return la + s; }else{ return lb + s + 1; } }else{ if (la <= lb) { return la + s; }else{ return Math.min(lb + Math.abs(a-b) + a,lb + (s-1) + a); } } } }