Fastest way to count how many possible solutions