First, capture, tag, and release a number of US senators. 15 or so should work. Then, reset your traps and capture some more. Count how many of the second capture set were tagged in the first group. This tells you what proportion of the population of Senators you captured the first time, and by dividing the number of senators you tagged by this proportion you can estimate the total population of senators. Divide that number by two to obtain the number of states.
Knowing that a bijection exists between states and stars on the US flag, first obtain a US flag. Observe that the stars in the top left corner fall in a rectangular n x m grid with stars located at every node, and also in the rows and columns in between, forming a smaller (n-1) x (m-1) rectangle, so the number of stars is nm + (n-1)(m-1). Then you can just count n and m - 6 and 5 respectively - and substitute to obtain 30+20=50 stars.