Solve this math problem

Solve -277 - 580 - 164 = -87*g + 545 for g.
18