package P126; import java.util.Scanner; public class P126 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String r = sc.nextLine(); String[] rstrs = r.split(" ",0); int a = Integer.parseInt(rstrs[0]); int b = Integer.parseInt(rstrs[1]); int s = Integer.parseInt(rstrs[2]); int ans = 0; if (Math.abs(s-a) <= Math.abs(s-b)) { ans = Math.abs(s-a) + (s-0); } else if (Math.abs(s-a) > Math.abs(s-b) && a >= 1) { ans = Math.abs(s-b) + Math.abs(s-a) + a; } else { ans = Math.abs(s-b) + Math.abs(s-1) + 2; } System.out.println(ans); } }