"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");

  let S = inputs[0];

  let minSub = Number.MAX_VALUE;
  for (let i = 0; i <= S.length - 3; i++) {
    let number = Number(S[i] + S[i + 1] + S[i + 2]);
    let sub = Math.abs(753 - number);

    if (sub < minSub) {
      minSub = sub;
    }
  }

  console.log(minSub);
}

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