The answer is:
18 years.
The explanation:
when Star 1 is 34 light years from Earth and Star 2 is 52 light years from Earth. that means the distance between star 1 and star 2 is 52-34 = 18 years so, If Star 2 explodes as a supernova so, the explosion would take 18 years to be seen from a planet orbiting Star 1.