#include<bits/stdc++.h>
#include<string>
using namespace std;

int main() {
string s;
cin >> s;
int ans =10e6;
for(int i=2;i<s.size();i++){
int che =(s.at(i-2)-'0')*100+(s.at(i-1)-'0')*10+s.at(i)-'0';
ans =min(ans,abs(che-753));
}
cout << ans <<endl;
}

