"use strict";
function Main (input) {
    const str = input.slice(0, 10);
    let res = Infinity;
    for(let i=0; i < str.length - 2; i++) {
        const num = parseInt(input.slice(i, i+3), 10);
        if (Math.abs(753 - res) > Math.abs(753 - num)) {
            res = num;
        }
    }
    console.log(Math.abs(753 - res));
}

//標準入力から文字列を受け取ってMain関数を実行
Main(require("fs").readFileSync("/dev/stdin", "utf8"));