By reflection across the diameter we can map what happens to the beam inside inside the semicircle to a full circle; them beam contacting the diameter and bounces off in the semicircle is equivalent to the beam passing through the diameter of the full circle.
We know that when the beam hits a wall, it reflects so that the angle of incidence equals the angle of reflection. By a simple angle-chase, we get that the beam hits the circle at points which forms 64 degree arcs.
After hitting the wall $n$ times the beam is at point $P$ on the circumference with $∠AOP=64n$. The beam first returns to $A$ when $360|64n$ or $n=45$. Thus the beam contacts the arc $AB$ 44 times, because we don't count when it hits $A$ at the end. The beam crosses from the upper half-circle to the lower half-circle or vice verca $64*45/180=16$ times, however this counts includes when the beam hits $A$ at the end, so it actually crosses $15$ times. The total numbner of contacts with the walls is then $44+15=59$.