Let number of basketball be "b", and number of football be "f".
We can write 2 equations from the statements.
"bought 5 less basketballs than footballs":

"Basketballs cost 26 and footballs cost 40 dollars each and total spent is 860 dollars":

We can substitute equation 1 into equation 2 and solve for b. Shown below:

Now, we can find f:

So,
10 basketballs bought and 15 footballs bought