Basic implementation of star counting algorithm