<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described.
<END_TASK>
<USER_TASK:>
Description:
Count numbers ( smaller than or equal to N ) with given digit sum
N can be max 10 ^ 18 and hence digitsum will be 162 maximum . ; If sum_so_far equals to given sum then return 1 else 0 ; Our constructed number should not become greater than N . ; If tight is true then it will also be true for ( i + 1 ) digit . ; Driver code

<ASSISTANT_TASK:>
Python Code:
def solve(i , tight , sum_so_far , Sum , number , length ) : 
	 if i == length : 
	 if sum_so_far == Sum : 
	 return 1 
  else : 
	 return 0 
   ans = dp[i ][tight ][sum_so_far ] 
 if ans != - 1 : 
	 return ans 
  ans = 0 
 for currdigit in range(0 , 10 ) : 
	 currdigitstr = str(currdigit ) 
 if not tight and currdigitstr > number[i ] : 
	 break 
  ntight = tight or currdigitstr < number[i ] 
 nsum_so_far = sum_so_far + currdigit 
 ans += solve(i + 1 , ntight , nsum_so_far , Sum , number , length ) 
  return ans 
  if __name__== "__main __": 
	 count , Sum = 0 , 4 
 number = "100"
 dp =[[[- 1 for i in range(162 ) ] for j in range(2 ) ] for k in range(18 ) ] 
 print(solve(0 , 0 , 0 , Sum , number , len(number ) ) ) 
 
<END_TASK>
