On finite groups with a certain number of centralizers