You need 5,000 to guarantee the best ending
but you can get it also with 4,000. You need to save Anderson, and choose the DESTROY ending
see here:
Mass Effect 3 Endings List