## https://yukicoder.me/problems/no/1929 def main(): n, S = map(int, input().split()) A = list(map(int, input().split())) if n == 1: a = A[0] if a > S: print(0) else: a_ = a k = 1 while a_ * a <= S: k += 1 a_ *= a print(k) return n1 = n // 2 n2 = n - n1 # 最大の指数の計算 array = [] for a in A: if a > S: print(0) return else: a_ = a k = 1 while a_ * a <= S: k += 1 a_ *= a array.append(k) # 半分全列挙 max_k_bit = 1 for i in range(n1): max_k_bit *= array[i] n1_value_set = {} for k_bit in range(max_k_bit): x = 0 is_ok = True for i in range(n1): k = k_bit % array[i] x += A[i] ** (k + 1) if x > S: is_ok = False break k_bit //= array[i] if is_ok: if x not in n1_value_set: n1_value_set[x] = 0 n1_value_set[x] += 1 n1_value_array = [(x, v) for x, v in n1_value_set.items()] n1_value_array.sort(key=lambda x : x[0]) cum_n1_value_array = [] cum_n1 = 0 for x, v in n1_value_array: cum_n1 += v cum_n1_value_array.append((x, cum_n1)) # n2についての処理 max_k_bit = 1 for i in range(n2): max_k_bit *= array[n1 + i] answer = 0 for k_bit in range(max_k_bit): x = 0 is_ok = True for i in range(n2): k = k_bit % array[n1 + i] x += A[n1 + i] ** (k + 1) if x > S: is_ok = False break k_bit //= array[n1 + i] if is_ok: if cum_n1_value_array[0][0] + x > S: continue low = 0 high = len(cum_n1_value_array) - 1 while high - low > 1: mid = (high + low) // 2 if cum_n1_value_array[mid][0] + x <= S: low = mid else: high = mid if cum_n1_value_array[high][0] + x <= S: answer += cum_n1_value_array[high][1] else: answer += cum_n1_value_array[low][1] print(answer) if __name__ == "__main__": main()