South Africa scored 286 in their first innings and then bowled India out for 209 on day two to take a 77-run lead in the first innings.