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