Scarcity of Ideas and Optimal R&D Policy