# your code goes here

class Solution(object):
    def countSubarrays(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: int
        """

        i = 0
        s = 0
        ans=0
        for j in range(len(nums)):
            s = s+nums[j]
            l = j-i+1
            while s >= k:
                s=s-nums[i]
                i=i+1
            ans+=j-i+1
        
        return ans
            

        