calculate number of gains and number of losses