the tree, bamboo pole and the ground will form a right triangle. the length of the pole is the hypotenuse of the right triangle form. so it can be solve using:
sin A = o / h
where A is the angle
o is the oposite side of the angle
h is the hypotenuse
h = o / sin a
h = 12.2 / sin 40
h = 18.7 m is length of the pole