#include <iostream>
#include <vector>
using namespace std;

#define REP(i,s,e) for (int i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)

int main() {
    int a, b, s, ans;
    cin >> a >> b >> s;
    int da = abs(s - a);
    int db = abs(s - b);

    if (da <= db)
        ans = da + s;
    else if (a == 0)
        ans = db + (s-1) + 2;
    else if (b >= abs(a-b))
        ans = db + abs(a-b) + a;
    else
        ans = db + (s-1) + a;
    cout << ans << endl;
    return 0;
}