program tenhous;
var m,n:longint;
a:array[1..1000000]of longint;
procedure init;
var i:longint;
begin
assign(input,'tenhous.in');
assign(output,'tenhous.out');
reset(input);
rewrite(output);
readln(n,m);
for i:= 1 to n do
read(a[i]);
end;
procedure work;
var i,lv,lc:longint;
begin
lv:=0;
lc:=0;
for i:= 1 to n do
begin
lc:=lc div 2;
inc(lc,a[i]);
if lc>=m then
begin
inc(lv);
dec(lc,m);
end;
end;
writeln(lv);
writeln(lc)
end;
begin
init;
work;
end.