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

int main (){
  string S;
  cin>>S;
  int n=S.size();
  int m=999;
  
  for(int i=0;i<n-2;i++){
    int x=S.at(i+2)-'0'+(S.at(i+1)-'0')*10+(S.at(i)-'0')*100;
    m=min(m,abs(x-753));
  }
  
  cout<<m;
}