input = gets.chomp x = input.chars.map{ _1.to_i } puts x.max - x.min