import std.stdio;
import std.string;
import std.conv;
import std.algorithm.comparison;
import std.algorithm.searching;

int[] a;
bool[3] b;
bool f;
uint nest = 0;
void check(){
	b = new bool[3];
	f = false;
	if(a[0] == a[1] && a[1] == a[2]){
		return;
	}
	auto mx = a.maxIndex;
	foreach(i,n; a){
		if(i != mx && n == a[mx]){
			f = true;
			break;
		}
	}
	if(f){
		a[a.minIndex] += 2;
	}else{
		b[mx] = true;
		for(int i = 0; i < 3; ++i){
			if(!b[i]){
				a[i]++;
			}
		}
	}
	nest++;
	check();
}
void main(){
	a = new int[3];
	readf("%d %d %d", &a[0], &a[1], &a[2]);
	check();
	nest.writeln;
}
