A farmer had a total of 995 horses and cows. After selling some of the horses and cows, he had 510 horses and 390 cows left. How many horses and cows did he sell altogether?