e=gets.chomp.split("").map{|e| e.to_i} puts e.max-e.min