Program ex;
var c:array[1..100] of integer; i,n,k:integer;
function s(a,b:integer):integer;
var x:integer;
begin
if a<=n then
begin
if (s(a+1,b-c[a])=1) or (s(a+3,b-c[a])=1) or (b=c[a]) then x:=1
else x:=0;
end
else x:=0;
s:=x;
end;
Begin
readln(n, k);
for i:=1 to n do read(c);
writeln(s(1,k));
end.
var c:array[1..100] of integer; i,n,k:integer;
function s(a,b:integer):integer;
var x:integer;
begin
if a<=n then
begin
if (s(a+1,b-c[a])=1) or (s(a+3,b-c[a])=1) or (b=c[a]) then x:=1
else x:=0;
end
else x:=0;
s:=x;
end;
Begin
readln(n, k);
for i:=1 to n do read(c);
writeln(s(1,k));
end.