S=io.read()
t={}
for i=1,#S-2 do
  t[i]=tonumber(string.sub(S,i,i+2))-753
    if t[i]<0 then 
      t[i]=-t[i]
    end
end
min=t[1]
for i=2,#S-2 do 
  if min>t[i] then
    min=t[i]
  end
end
print(min)