From paper "An Optimal Algorithm for the Distinct Elements Problem"