<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $n = strlen($s);
  $ans = PHP_INT_MAX;
  for ($i=0; $i<$n-2; $i++) {
    $value = $s[$i].$s[$i+1].$s[$i+2];
    $ans = min($ans, abs($value-753));
  }
  echo $ans;