#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define insum(a, b)  a = modsum(a, (b))
#define insubtract(a, b) a = modsubtract(a, (b))
#define inmultiply(a, b) a = modmultiply(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#ifdef MAX_HOME
#define watch(x) cout << (#x) << " = " << x << endl;
#else
#define watch(x) cerr << (#x) << " = " << x << endl;
#endif

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template<class T>
ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    for (auto x : a) out << x << " ";
    return out << "}";
}

template<class T>
ostream & operator << (ostream &out, pair<T, T> &a) {
    out << "{";
    cout << a.first << ", " << a.second;
    return out << "}";
}

void smain();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
#endif

    cout << setprecision(12) << fixed;

    smain();
}
/* END OF TEMPLATE ========================================================================================================================================== */;

const int N = 109;
const int oo = 1e9 + 7;
int dp[N][N][N];

inline bool in(int a) {
    return a >= 0 && a < N;
}

inline bool in_bounds(int a, int b, int c) {
    return in(a) && in(b) && in(c);
}

void smain() {

    fori (i, N) fori (j, N) fori (k, N) {
        if (i == j && j == k) dp[i][j][k] = 0;
        else dp[i][j][k] = oo;
    }
    for (int i = N - 1; i >= 0; --i) for (int j = N - 1; j >= 0; --j) for (int k = N - 1; k >= 0; --k) if (dp[i][j][k]){
            int ni = i, nj = j, nk = k;
            ni++, nj++;
            if (in_bounds(ni, nj, nk)) inmin(dp[i][j][k], dp[ni][nj][nk]);
            ni--, nj--;

            ni++, nk++;
            if (in_bounds(ni, nj, nk)) inmin(dp[i][j][k], dp[ni][nj][nk]);
            ni--, nk--;

            nj++, nk++;
            if (in_bounds(ni, nj, nk)) inmin(dp[i][j][k], dp[ni][nj][nk]);
            nj--, nk--;

            ni += 2;
            if (in_bounds(ni, nj, nk)) inmin(dp[i][j][k], dp[ni][nj][nk]);
            ni -= 2;

            nj += 2;
            if (in_bounds(ni, nj, nk)) inmin(dp[i][j][k], dp[ni][nj][nk]);
            nj -= 2;

            nk += 2;
            if (in_bounds(ni, nj, nk)) inmin(dp[i][j][k], dp[ni][nj][nk]);
            nk -= 2;
            if (dp[i][j][k] != oo) dp[i][j][k]++;
//            if (max(i, max(j, k)) < 10) cout << "dp[" << i << "][" << j << "][" << k << "] = " << dp[i][j][k] << endl;
        }
    int a, b, c;
    cin >> a >> b >> c;
    cout << dp[a][b][c];
}



Measured memory_bytes: 5376