Three militants killed in Afghanistan attack