import std.algorithm, std.conv, std.stdio, std.string; immutable long MO = 1_234_567_891; void add(ref long t, in long f) { if ((t += f) >= MO) { t -= MO; } } void main() { string[] tokens; tokens = readln.chomp.split(" "); const N = tokens[0].to!int; const M = tokens[1].to!long; tokens = readln.chomp.split(" "); auto A = new int[N]; foreach (i; 0 .. N) { A[i] = tokens[i].to!int; } const ASum = A.reduce!((a, b) => a + b); auto dp = new long[ASum * 2]; dp[0] = 1; foreach (j; 0 .. 64) { foreach (i; 0 .. N) { foreach_reverse (x; A[i] .. ASum * 2) { add(dp[x], dp[x - A[i]]); } } foreach (x; 0 .. ASum) { dp[x] = dp[x << 1 | ((M >> j) & 1)]; } dp[ASum .. $] = 0; } writeln(dp[0]); }