#include using namespace std; int main() { int a, b, s; cin >> a >> b >> s; if (abs(a - s) <= abs(b - s)) { cout << (abs(a - s) + s) << endl; } else { if (a >= 1) { cout << abs(b - s) + a + min(abs(a - s), s - 1) << endl; } else { cout << abs(b - s) + (s - 1) + 2 << endl; } } }