Hey @Tinkle,
If the shares are being transferred as a gift, for relatives, gifts are exempted from taxes.
Hence, when these shares are being gifted neither the sender nor the receiver needs to pay taxes on it.
Now, when the shares are sold, capital gains will arise in the hands of the receiver, i.e. person B in your case. They will have to pay taxes on the gains based on whether the gains are short-term or long-term.
Here’s a detailed thread about tax implications on gifted shares, do give it a read. How are gifted shares taxed?
Let me know if you have any further doubts.