import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

int[int[]] memo;
int dfs(int[] a, int depth = 0)
{
	if (a.reduce!max >= 100) {
		return 1 << 28;
	}
	if (a in memo) {
		return memo[a];
	}
	if (a[0] == a[1] && a[0] == a[2]) {
		return depth;
	}
	int ans = int.max;
	for (int i = 0; i < 3; ++i) {
		for (int j = i + 1; j < 3; ++j) {
			int[] b = a.dup;
			b[i]++;
			b[j]++;
			ans = min(ans, dfs(b, depth + 1));
		}
	}
	for (int i = 0; i < 3; ++i) {
		int[] b = a.dup;
		b[i] += 2;
		ans = min(ans, dfs(b, depth + 1));
	}
	memo[a.idup] = ans;
	return ans;
}

void main()
{
	auto arr = readln.chomp.split.map!(to!int).array;
	dfs(arr).writeln;
}
