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

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