local str = io.read()
local n = tonumber(str)
local min = 753
for i=1,#str-2 do
	local newmin = math.abs(753 - tonumber(string.sub(str,i,i)..string.sub(str,i+1,i+1)..string.sub(str,i+2,i+2)))
	if min > newmin then min = newmin end
end
print(min)