@colors = [
    [0, "black", 0, 0, 0],
    [1, "blue", 0, 0, 255],
    [2, "lime", 0, 255, 0],
    [3, "aqua", 0, 255, 255],
    [4, "red", 255, 0, 0],
    [5, "fuchsia", 255, 0, 255],
    [6, "yellow", 255, 255, 0],
    [7, "white", 255, 255, 255]
]

def color str
    r = str[1..2].to_i(16)
    g = str[3..4].to_i(16)
    b = str[5..6].to_i(16)
    arr = []
    @colors.each{|index, name, rk, gk, bk|
        arr << [index, name, (r-rk)**2 + (g-gk)**2 + (b-bk)**2]
    }
    arr.sort_by{|i, n, d| [d, i]}.first[1]
end

while true
    line = gets.chomp
    break if line == "0"
    puts color(line)
end
