The Optimal Timing of Affirmative Action