Count k for consecutive-sum generator | Microsoft