Number of connected gamepads

Hi, does anyone know how can I check how many gamepads are connected. I need it for the split screen menu. I want to replace “1 gamepad controllers must be connected…” with “please connect gamepad”. Image below.

Thanks