title: Kotlin flow: collect only elements which repeat at least N times
body: <p>I am implementing ML Kit OCR feature and sometimes, the first several values are wrong and only after some time the camera stabilizes and produces correct values. I do not want to drop first X values because I do not know how many elements the flow would contain. So the best way would be to use some condition, which compares the current element with the previous one, but not sure.</p>
  
  <p>Is there a function in Kotlin Flow API which will compare collected values and will collect only the one which occurred at least N times?</p>
  
  <pre><code>  private val _detectedValues = ConflatedBroadcastChannel&lt;String&gt;()
    val detectedFlow = _detectedValues
        .asFlow()
        .map { it.replace(" ", "") }
        .filter { it.checkRegex() }
        .onEach {
            Log.i(TAG, "detected: $it")
        }
  </code></pre>