def count_windows(nums, k, threshold):
    if k < 1 or k > len(nums):
        return 0
    total = sum(nums[:k])
    count = int(total >= threshold)
    for right in range(k, len(nums)):
        total += nums[right] - nums[right - k]
        count += int(total >= threshold)
    return count
