process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
  var N = lines[0];
  var diff = [];
  for(var i=0; i<N.length-2; i++){
    var pick_num = N.slice(i, i+3);
    var sabun = Math.abs(753-pick_num);
    diff.push(sabun);
  }
  var result = Math.min(...diff)
  console.log(result);
});