Let Mathew has x number of marbles and David has y number of marbles.
Also given Joseph has s 5 times as many marbles as Matthew has. Therefore Joseph has 5x marbles
Given
David and Joseph have a total of 328 marbles, that is
5x+y=328.......(1)
Also given
Matthew and David have 176 marbles, that is
x+y=176.........(2)
(1)-(2) implies
4x=152
x=38
therefore from (2)
y=176-38=138
David has 138 marbles