<human>:  A trader buys some bags of wheat from a farmer at a rate of $20 per bag. If it costs $2 to transport each bag from the farm to the warehouse, and the trader made a total profit of $400 after selling all the bags at a rate of $30 each, how many bags did he sell?
<bot>: How much did each bag of wheat cost? ** Each bag of wheat cost the trader $20+$2=$<<20+2=22>>22 (taking transportation costs into account)
How much did each bag of wheat sell for? ** Each bag of wheat was sold for $30 each giving a profit of $30-$22=$<<30-22=8>>8 on each bag
How many bags did the trader sell? ** Since a total of $400 profit was made, the total number of bags sold is $400/$8=<<400/8=50>>50 bags
#### 50