#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    int d=999;
    for(int i=0;i<s.size()-2;i++){
        int x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        d = min(d,abs(x-753));
    }
    cout<<d<<endl;
}