Mario’s hat is four more than Alex’s hat and one-half that of Gabriel’s hat. If the total number of hats is 24, how many hats does Alex have?

Mario’s hat is four more than Alex’s hat and one-half that of Gabriel’s hat. If the total number of hats is 24, how many hats does Alex have?