'use strict';
const input = require("fs").readFileSync("/dev/stdin", "utf8");
let l = [];
for (let i=0;i<input.length-2;i++) {
  let r = Number(input.substr(i, 3));
  l.push(Math.abs(r - 753));
}
console.log(Math.min.apply(null,l));