#include <iostream>
using namespace std;

int main()
{
  int ans(1000);
  string s;
  cin >> s;
  for (int i = 0; i <= s.length() - 3; i++) {
    ans = min(ans, abs(stoi(s.substr(i, 3)) - 753));
  }
  cout << ans << endl;
}
