#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
//typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
#define all(n) (n).begin(), (n).end()
#define Size(n) ((ll)(n).size())
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define FOR(i, a, n) for (register ll i = (a); i < (ll)(n); ++i)
#define PI 3.141592653589793
#define mod 1000000007
#define M 100006
# define N 100005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
# define inf (ll)1e18
# define A 1000006
# define offset 10002

struct node
{
    int u,v,w;
};

int d[100][100][100];
bool vis[100][100][100];
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    queue<pair<int,pair<int,int> > >q;
    q.push(mp(a,mp(b,c)));
    d[a][b][c]=0;
     vis[a][b][c]=1;
    while(!q.empty())
    {
       int a1=q.front().ff;
       int b1=q.front().ss.ff;
       int c1=q.front().ss.ss;
       //trace3(a1,b1,c1);
       q.pop();
       if(a1>=55 || b1>=55 || c1>=55)
        continue;
       if(a1==b1 && b1==c1)
       {
        cout << d[a1][b1][c1];
        break;
       }
       if(!vis[a1+1][b1+1][c1])
       {
         d[a1+1][b1+1][c1]=d[a1][b1][c1]+1;
         vis[a1+1][b1+1][c1]=1;
         q.push(mp(a1+1,mp(b1+1,c1)));
       }
       if(!vis[a1+1][b1][c1+1])
       {
         d[a1+1][b1][c1+1]=d[a1][b1][c1]+1;
         vis[a1+1][b1][c1+1]=1;
         q.push(mp(a1+1,mp(b1,c1+1)));
       }
       if(!vis[a1][b1+1][c1+1])
       {
         d[a1][b1+1][c1+1]=d[a1][b1][c1]+1;
         vis[a1][b1+1][c1+1]=1;
         q.push(mp(a1,mp(b1+1,c1+1)));
       }
       if(!vis[a1+2][b1][c1])
       {
         d[a1+2][b1][c1]=d[a1][b1][c1]+1;
         vis[a1+2][b1][c1]=1;
         q.push(mp(a1+2,mp(b1,c1)));
       }
       if(!vis[a1][b1+2][c1])
       {
         d[a1][b1+2][c1]=d[a1][b1][c1]+1;
         vis[a1][b1+2][c1]=1;
         q.push(mp(a1,mp(b1+2,c1)));
       }
       if(!vis[a1][b1][c1+2])
       {
         d[a1][b1][c1+2]=d[a1][b1][c1]+1;
         vis[a1][b1][c1+2]=1;
         q.push(mp(a1,mp(b1,c1+2)));
       }
    }
}

Measured memory_bytes: 3584