class Solution(object):
    def combinationSum4(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        ways = [0 for i in range(target+1)]
        
        for i in range(1, len(ways)):
            for n in nums:
                if n > i:
                    continue
                if n == i:
                    ways[i] += 1
                else:
                    ways[i] += ways[i-n]
        
        return ways[target]