Retirement tax questions

What you described in the beginning of your post sounds very similar to my situation and I desperately need help right now.

 

I took a total distribution of my ESOP account from my former employer and they issued me a stock certificate for the entire balance from my ESOP account in October 2021 which is 8909 shares. I then deposited the stock certificate to my TD Ameritrade  account and sold 6709 shares in November 3. The 1099-R I received from my former employer shows the same amount in box 1 and box 2a. There is an amount box 6 NUA that is close to the total proceeds of my sale of the 6709 but not the exactly equal. It is about $3k higher. The 1099-B I received from TD Ameritrade does not have a cost basis information. How do I enter these info to minimize my tax liability? Is the amount in the box 2a of my 1099-R really what should be taxed? I did not even sell all of the shares I received and now the remaining value is less than 50% of what was reported. What would the cost basis be in the 1099-B report? Shall I report this a short term or long term sale? I need help. Thank you!