#include <iostream>

int main()
{
	int a, b, c, count = 0, max = 0;
	int s1, s2, s3;
	std::cin >> a >> b >> c;
	if(max < a)
	{
		max = a;
	}
	if(max < b)
	{
		max = b;
	}

	if(max < c)
	{
		max = c;
	}
	//std::cout << max << std::endl;

	while(1)
	{
		if(a == b &&  a == c)
		{
			break;
		}else if(max == b){
			s1 = max - a;
			s2 = max - c;
			if(s1 == s2)
			{
				a = a + 1;
				c = c + 1;
				count++;
					//std::cout << count << std::endl;
					//std::cout << a << " " << b << " " << c << std::endl;
				if(a == max && c == max)
				{
					break;
				}
			}else if(a < max && c < max){
				a = a + 1;
				c = c + 1;
				count++;
					//std::cout << a << " " << b << " " << c << std::endl;
			}else if (max == a){
				s3 = max - c;
				if(s3 % 2  == 0)
				{
					c = c + 2;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}else{
					b++;
					max++;
					a++;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}
			}else if(max == c){
				s3 = max - a;
					//std::cout << s3 << std::endl;
				if(s3 % 2  == 0)
				{
					a = a + 2;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}else{
					b++;
					max++;
					c++;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
					
				}
			}
		}else if(max == a){
			s1 = max - b;
			s2 = max - c;
			
			if(s1 == s2)
			{
				b = b + 1;
				c = c + 1;
				count++;
					//std::cout << count << std::endl;
					//std::cout << a << " " << b << " " << c << std::endl;
				if(b == max && c == max)
				{
					break;
				}
			}else if(b < max && c < max){
				b = b + 1;
				c = c + 1;
				count++;
					//std::cout << a << " " << b << " " << c << std::endl;
			}else if (max == b){
				s3 = max - c;
				if(s3 % 2  == 0)
				{
					c = c + 2;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}else{
					b++;
					max++;
					a++;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}
			}else if(max == c){
				s3 = max - b;
					//std::cout << s3 << std::endl;
				if(s3 % 2  == 0)
				{
					b = b + 2;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}else{
					a++;
					max++;
					c++;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
					
				}
			}
		}else if(max == c){
			s1 = max - b;
			s2 = max - a;
			if(s1 == s2)
			{
				b = b + 1;
				a = a + 1;
				count++;
					//std::cout << count << std::endl;
					//std::cout << a << " " << b << " " << c << std::endl;
				if(b == max && a == max)
				{
					break;
				}
			}else if(b < max && a < max){
				b = b + 1;
				a = a + 1;
				count++;
					//std::cout << a << " " << b << " " << c << std::endl;
			}else if (max == b){
				s3 = max - a;
				if(s3 % 2  == 0)
				{
					a = a + 2;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}else{
					b++;
					max++;
					c++;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}
			}else if(max == a){
				s3 = max - b;
					//std::cout << s3 << std::endl;
				if(s3 % 2  == 0)
				{
					b = b + 2;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
				}else{
					a++;
					max++;
					c++;
					count++;
						//std::cout << a << " " << b << " " << c << std::endl;
					
				}
			}
		}
	}
	std::cout << count << std::endl;
	return 0;
}

Measured memory_bytes: 256