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

int main() {
  string S;
  cin >> S;
  int ans=753;
  for (int i=0; i<=S.size()-3; i++) {
    int a=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
    ans=min(ans, abs(753-a));
  }
  cout << ans << endl;
}
