How to deduct cost of restricted stock sold for future payouts

My company (A) merged with company (B) on 9/1.  The day before the merger, company A paid out all retained earnings to the stockholders who all have vested restricted stock.  I payed taxes on the awarded stock (83b election) in 2013.  We were paid zero for the stock transferred to company B.  Company B will pay a share of profits to company A original stockholders over 3 years.

The payout of retained earnings was substantial and reported as qualified dividends.  Is there any way I can deduct my original cost?  What happens if the future earnings don't pan out or I resign and forfeit them.  How can I still deduct my cost?