import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(),b = sc.nextInt(),s = sc.nextInt(),count = 0; if(Math.abs(a - s) <= Math.abs(b - s) || s == 1) { count += Math.abs(a - s) + s; }else { count += Math.abs(b - s); if(Math.abs(s - a) + a > (s - 1) + a) { count += s - 1 + a; if(a == 0)count += 2; }else { count += Math.abs(s - a) + a; } } System.out.println(count); } }