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