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) + (s - 1) + a; System.out.println(count); } }