function Main(input) {
  inp = input.split("\n")[0];
  var ans = 890016;
  for(var i = 0; i < inp.length - 2; i++) {
    ans = Math.min(ans, Math.abs(753 - parseInt(inp.slice(i, i + 3))));
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));