The farmer can take to the village 334 apples to sell. In the meantime, ultimately selling these 334 apples will have cost him 1666 apples.
My thinking is based on the hint MK gave us.
If the farmer throws one apple on the roadside per kilometer while the donkey walks, then the first batch of 1000 apples can take him up to 333 km along the way, before the donkey has to return because the apples will have run out. So, the donkey eats 333 apples on the way to the village, 333 on the way back, and 334 are left on the roadside.
Route 2: the donkey eats the apples on the road, until the 334th km has been covered, and then it starts eating from the batch it's carrying. That means it'll need another 666 apples to go all the way, and the farmer can sell the 334 remaining ones.
But then, how does the donkey go back to the first village? Oh, I know: the farmer sells the donkey at the village, too, dumps his wife and spends all the money at the local whorehouse!