Maintain a set S of 9 elements, each with a counter. Think of the following function: f(x) = counter(x), if x in S - Sum_{y in S} counter(y), if x not in S You want to guarantee the following properties: * when x is seen in the stream, f(x) increases by 9 * when some element other than x is seen, f(x) decreases by at most 1 Then, at the end, f(x) is positive for all frequent elements. If f(x) > 0, it must be that x is in S.