#include <bits/stdc++.h>

int main()
{
	long long s{}, min{1000};
	scanf("%lld", &s);
	while (s >= 100)
	{
		min = std::min(std::abs(s % 1000 - 753), min);
		s /= 10;
	}
	printf("%lld\n", min);

	return 0;
}