s = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0]
min = 10000
for (i=0; i<s.length-2; i++) {
    a = Math.abs(753 - s.slice(i, i+3) * 1)
    if (min > a) {
        min = a
    }
}
console.log(min)