completed counting of 1's in binary