Let's use the variable x to represent the number of small carts and y to represent the number of big carts.
Since the total number of carts is 15, we have the equation:

And if the total number of people that can ride at one time is 40, we have the equation:

From the first equation, let's isolate y and use its value in the second equation:

Therefore there are 10 small carts and 5 big carts.