def bb
    n = gets.chomp.to_i

    o = [0, 111, 222, 333, 444, 555, 666, 777, 888, 999]
    for i in 0..(o.length-2)
        if o[i] < n and n <= o[i+1]
            puts o[i+1]
            exit
        end
    end
end

bb