Over the four hours, the tank loses 2 * 4 = <<2*4=8>>8 gallons of water.
Hayden adds a total of 1 + 3 = <<1+3=4>>4 gallons of water.
At the end of the four hours, there is 40 - 8 + 4 = <<40-8+4=36>>36 gallons of water left in the tank.
#### 36