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