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 s = lines[0];
 var length = s.length;
 var kouho = [];
 var sa = [];

for(i=0; i<length; i++){
  var a = s.substring(i,3+i)
  kouho.push(a);
  var b = Math.abs(Number(a) - 753);
  sa.push(b);
}
 var min = Math.min(...sa);  
 

 console.log(min);
});