#include <bits/stdc++.h>

using namespace std;

int main() {
  int m=999;
  string S;
  cin >> S;
  for (int j=0; j < S.size(); ++j) {
    string s = S.substr(j, 3);
    int si = stoi(s);
    m = min(m, abs(753-si));
  }
  cout << m << endl;
}