Text this: Counting multiple X-rays per pulse with an avalanche photodiode detector