First you can purchase only one house with one Capital gains . You cannot club 2 CG and invest in one property.
With regards to the capital gains from sale of shares, the tax implications would depend on the period of holding of shares from date of acquisition. The period of holding for unlisted shares to qualify as long-term asset has been increased from 12 months to 36 months.The LTCG could be claimed as exempt from tax by investing in prescribed investment avenues, i.e., residential apartment or specified bonds, subject to the fulfilment of conditions specified under the domestic tax law.
In the present case you can choose which CG you will invest in residential property or CG. As on one CG you shall pay tax.