#include <iostream>
#include <cmath>
using namespace std;
string s;
int ans=999432;
int main()
{
	cin >> s;
	for(int i=0; i<s.size()-2; i++)
	{
		int N=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		
		ans=min(ans,abs(753-N));
	}
	cout << ans;
}