<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def count_matching(self, selector, offset=0):
 """Count the number of readings matching selector. Args: selector (DataStreamSelector):
 The selector that we want to count matching readings for. offset (int):
 The starting offset that we should begin counting at. Returns: int: The number of matching readings. """


        if selector.output:
            data = self.streaming_data
        elif selector.buffered:
            data = self.storage_data
        else:
            raise ArgumentError("You can only pass a buffered selector to count_matching", selector=selector)

        count = 0
        for i in range(offset, len(data)):
            reading = data[i]

            stream = DataStream.FromEncoded(reading.stream)
            if selector.matches(stream):
                count += 1

        return count