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