import std.stdio,std.ascii,std.conv,std.string,std.algorithm,std.range,std.functional,std.math,core.bitop;

void main(){
    auto ar=array(map!(to!int)(readln().strip().split()));
    int count=0;
    int[] b;
    foreach(i,n;ar){
        b~=n;
    }
    while(true){
        if(array(ar.filter!(a=>ar.reduce!"min(a,b)"==a)).length==3){
            break;
        }
        foreach(ref n;b){
            if(array(ar.filter!(a=>ar.reduce!"min(a,b)"==a)).length==2){
                if(n==ar.reduce!"min(a,b)"){
                    n+=1;
                }
            }else{
                if(n==ar.reduce!"min(a,b)"){
                    n+=2;
                }
            }
        }
        foreach(i,n;b){
            ar[i]=n;
        }
        count++;
    }
    writeln(count);
    
}