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


int main() {
   string s;
   cin>>s;

   int ans=1000;
   for (int i = 0; i < s.size()-2; ++i){
      int a=(s[i]-48)*100+(s[i+1]-48)*10+s[i+2]-48;
      ans=min(ans,abs(753-a));
   }

   cout<<ans<<endl;

}