Non Shariah compliant investment by mistake

Assalamu Alaykum. I have recently bought some shares and just realised it did not comply with 33% debt screening rule to make the investment shariah compliant (I was not aware of this ruling at the time of purchasing the shares and learned about the requirement only recently). Please could a mufti clarify if I can sell the shares and recover the original money I invested e.g. If I bought shares worth £2000, can I sell the shares and recover the £2000 I invested or do I need to donate the full 2000 to charity?
JazakAllah khair