k,t,s,a;main(b){scanf("%d%d%d",&a,&b,&s);k=!printf("%d",s-1&&(k=abs(s-a))>(t=abs(s-b))?t+a+(s>k?k:s-1+2*!a):k+s);}