'use strict'

function Main(input) {
    const S = input.trim()
    const output = operate(S)
    console.log(output)
}

function operate(S) {
    let detMin = null
    for (let i = 0; i < S.length - 2; i++) {
        const n = parseInt(S.substring(i, i + 3))
        const det = Math.abs(753 - parseInt(S.substring(i, i + 3)))
        if (detMin == null || det < detMin) {
            detMin = det
        }
    }
    return detMin
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));