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