import Control.Applicative
import Control.Monad
import Data.List

solve [a, b, c] = abs (read [a,b,c] - 753)
solve (a:r@(b:c:_)) = min (abs (read [a,b,c] - 753)) $ solve r

main = getLine >>= print . solve