# frozen_string_literal: true

numbers = gets.split("")

min_diff = Float::INFINITY
numbers.each_cons(3) {|array|
  diff = (753 - array.join.to_i).abs
  min_diff = diff if diff < min_diff
}

puts min_diff
