"use strict";

function Main(input) {
  let line = input;
  let min = Infinity;
  for(let i = 0; i < input.length-2; i++){
  	let num = line.slice(i,i+3)*1;
    let diff = Math.abs(num - 753);
    if(min > diff) {
      min = diff;
    }
  }
  console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));