Given,
2n2+3n1=18
2n2−3n1=6
Solving these two equations, we get n1=2, n2=6.
So total number of photons when electrons transit to n1 shell will be (x)=(n2−n1+1)(n2−n1)2 = (6−2+1)(6−2)2 = 10
Photons in Balmer range (visible range) will be 6→2,5→2,4→2,3→2
So, number of photons in Balmer range will be (y)=4
x+y=14