Hello,
Assuming there are Q consecutive bags and each bag can contain at most 1 ball. Find the probability of finding N balls in the first M consecutive bags.
Assuming N<=M<=Q, and P is the probability that any given bag contains a ball:
C(M,N) * P^N * (1-P)^(M-N)
where C(M,N) is the number of combinations of M things taken N at a time.