You need to memorize a formula for these kind of problems:
Total/(A+B)*B
Where total means total substance(in this case 869)
A means other substance ratio(in this case 7)
B means substance ratio of amount you are trying to solve for(in this case 4)
869/(7+4)*4=316