Learning set cardinality in distance nearest neighbours