First, find a number that is divisible by 6,7 and 8. This number is the lowest common multiple (LCM) of these numbers. The LCM of 6,7 and 8 is 168. (2*3*7*4). When we divide 168 marbles equally among 6 or 7 or 8 students, there will be no marbles left over. To have 4 marbles left over in all cases, we should add 4 to the number we already have. So the total number of marbles in the box will be 168+4=172.