"use strict";
const input = require("fs").readFileSync("/dev/stdin","UTF-8").trim();

let minDiff = 1000;
const NUM = 753;
for (let i=0;i<input.length-2; i++) {
  const num = Number(input.slice(i,i+3));
  const diff = Math.abs(num-NUM);
  if(diff < minDiff) minDiff = diff;
}

console.log(minDiff);