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 l1 = Math.abs(S - A); int l2 = Math.abs(S - B); if(l1 < l2) { int ans = l1 + S; System.out.println(ans); }else { int ans = l2; if(A >= S) { if(A - S >= S) { ans += S + A - 1; }else { ans += A - S + A; } }else { ans += S - A + A; } System.out.println(ans); } } }