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