Get your taxes done using TurboTax

See IRS Pub 550 Chapter 4 sections on cost basis and average basis .

You'll have to take reinvested dividends into account sooner or later once the first 400 shares are sold.