Question on amount of education account distribution to exclude from additional tax

I would like to know how to compute Line-6 in Form 5329 in the following:

Let's say -

1. I had 1098-T of $500 in box1 as well as box5 (scholarship, grant)

2. I had 1099-Q from a 529 account of box 1 $800 and box2 $700

I understand that I will have to pay tax and additional 10% tax on the edu acct withdrawal.

My question is - can I exempt the full $ 500 from this additional 10% in line-6 of form 5329 ?

However, turbotax computes it as 700 * (500/800) meaning the proportionate amount from the earnings

and allows me to exempt only $437.50(438) as the amount exempt from 10% tax.

 

I tested the same scenario in TaxAct but that software simply asks me to manually enter the line-6 5329.

It does not even to attempt to compute that automatically.

 

I checked the instructions for Line-6.

Could someone give me pointers on where this is explained by IRS ? What is the correct calculation ? Is it full or proportionate ?