Non-halal index funds

I found out that a Fidelity index fund that I have owned for over 20 years is 30% non-sharia compliant. I do not have the income or dividend data over the years.

  1. As a first step I am going to switch to a sharia compliant fund.

  2. However, how, do I purify the money that is in the fund and has grown over the years? Do I need to give 30% of the money away or do I donate 5-10% of the 30%?