Initially let the number of t-shirts of Pepe, Levis and Adidas with Harry be 5x, x and 4x respectively Let the number of gifted t-shirts of Pepe and Adidas be y and z. Now, number of t-shirts of Pepe left with Harry becomes 5x-y Number of t-shirts of Levis left with Harry becomes x Number of t-shirts of Adidas left with Harry becomes 4x-z
x, y and z should be whole numbers as the number of t-shirts cannot be negative or fractions
So, $$\frac{\left(5x-y\right)}{x}=\frac{5}{3}$$
$$15x-3y=5x$$
For y to be a whole number, x should be a multiple of 3
Similarly, $$\frac{\left(4x-z\right)}{x}=\frac{7}{3}$$
$$12x-3z=7x$$
$$z=\frac{5}{3}x$$
For z to be a whole number, x should be a multiple of 3
So, from above two conditions x should be a multiple of 3
Total number of t-shirts initially with Harry$$=5x+x+4x=10x$$
To minimize the total number of t-shirts initially with Harry the minimum possible value of x is 3.
Therefore $$10x=30$$
Alternate Method:
Initially let the number of t-shirts of Pepe, Levis and Adidas with Harry be 5x, x and 4x respectively.
Let the final number of t-shirts of Pepe, Levis and Adidas with Harry be 5y, 3y and 7y respectively.
Now, x=3y
Therefore, Total no. of t-shirts initially with Harry =5x+x+4x=10x = 30y
So, minimum no. of t-shirts initially with Harry will be 30.