#include <bits/stdc++.h>

using namespace std;

int main() {
	string s;
	cin >> s;
	int m = 10000;
	for (int i = 0; i < s.length() - 2; i++)
		m = min(m, abs(stoi(s.substr(i, 3)) - 753));
	cout << m << endl;
	return 0;
}
