#include<bits/stdc++.h>
using namespace std;
int main() {

	string s;
	int minz = INT16_MAX;
	cin >> s;

	for (int i = 0; i < s.length(); i++)
	{
		int t = stoi(s.substr(i, 3));
		

		minz = min(abs(753 - t), minz);
	}
	cout << minz << endl;
}


