#include using namespace std; int main(){ int A, B, S; cin >> A >> B >> S; int AS = abs(A - S); int BS = abs(B - S); if(AS <= BS){ cout << AS + S << endl; } else if(A > 0){ cout << BS + AS + A << endl; } else { cout << BS + S + 1 << endl; } return 0; }