mod = 998244353 def main(): import sys from bisect import bisect_left input = sys.stdin.readline N, S = map(int, input().split()) A_ori = list(map(int, input().split())) A_split = [A_ori[:4], A_ori[4:]] res_list = [] for A in A_split: dp = {0: 1} for a in A: ax = 1 dp_new = {} for x in range(31): ax *= a if ax > S: break for y in dp: y_new = y + ax if y_new > S: continue if y_new not in dp_new: dp_new[y_new] = 0 dp_new[y_new] += dp[y] dp = dp_new res = [] for y in dp: res.append((y, dp[y])) res.sort(key=lambda z: z[0]) res_list.append(res) res0, res1 = res_list val = [] cnt_cs = [0] for y, c in res1: val.append(y) cnt_cs.append(cnt_cs[-1] + c) ans = 0 for y, c in res0: j = bisect_left(val, S - y + 1) ans += cnt_cs[j] * c print(ans) if __name__ == '__main__': main()