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 ans; if (s == 1 || Math.abs(s - a) <= Math.abs(s - b)) { ans = Math.abs(s - a) + s; } else if (a == 0) { ans = Math.abs(s - b) + s + 1; } else { ans = Math.min(Math.abs(s - b) + s - 1 + Math.abs(a - 1) + 1, Math.abs(s - b) + Math.abs(s - a) + a); } System.out.println(ans); } }