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