require 'pp'
require 'set'

chs = gets.chomp!.chars

ans = 9999999999
chs.each_cons(3) do |x|
    num = x.join.to_i
    diff = (num - 753).abs 
    if diff < ans
        ans = diff
    end
end

puts ans
