Draw a right angle triangle and the base is 100m
The height is divided into 2 parts: from the ground to the top of the building (let's say x) and from the top of the building to the top of the flagpole (let's say x + y)
So,
tan 54.5 = (x + y)/100
tan 51.8 = x/100
First, solve for x, then solve for y