# permCalc.py 
# Fig. 30.1 
# inputs: 9 8  or 3 8
'''
k size subset of d; and count those that
have a sum of tot or more

'''

d = [ -3, 5,10,-17, -3, -7, 3,-3, 4,- 7,
      -3,-9, 2, -6, -1, 1, -1,-3 ]

k,tot = map(int, input("k tot=? ").split())
count = 0
s = 0
c = [i for i in range(k)]
while True:
  # print(c)
  for i in range(k):
    s += d[c[i]]
  if s >= tot:
    count += 1
  j = k-1
  s = 0
  while c[j] == len(d)-k+j:
    j -= 1
  c[j] += 1 
  for i in range(j+1,k):
    c[i] = c[i-1] +1
  if j == -1:
    break
print("count ==", count)
