Obama: Troops may remain in Afghanistan beyond war