Finding the majority element in an input stream