const
  maxn = 20;
var
  n, k, i, j, m, maxcnt, maxmask, ansc, ii : longint;
  a, b, c, ans : array[1..maxn] of longint;
  prev, cnt, d : array[1..1 shl maxn] of longint;
begin
  reset(input, 'meetings.in');
  rewrite(output, 'meetings.out');
  read(n, k);
  for i := 1 to n do begin
    read(a[i], b[i], c[i]);
  end;
  m := 1 shl n;
  for i := 0 to m - 1 do begin
    prev[i] := 0;
    cnt[i] := 0;
    d[i] := 0;
    for j := 1 to n do begin
      if (i and (1 shl (j - 1)) <> 0) then begin
        cnt[i] := cnt[i] + 1;
        d[i] := d[i] + c[j];
        ii := i xor (1 shl (j - 1));
        if ((ii = 0) or (prev[ii] <> 0)) and (k + d[ii] >= a[j]) and (k + d[ii] <= b[j]) then begin
          prev[i] := j;
        end;
      end;
    end;
  end;
  maxcnt := 0;
  maxmask := 0;
  for i := 0 to m - 1 do begin
    if (prev[i] <> 0) and (cnt[i] > maxcnt) then begin
      maxcnt := cnt[i];
      maxmask := i;
    end;
  end;
  writeln(maxcnt);
  ansc := 0;
  while (maxmask <> 0) do begin
    ansc := ansc + 1;
    ans[ansc] := prev[maxmask];
    maxmask := maxmask xor (1 shl (prev[maxmask] - 1));
  end;
  for i := ansc downto 1 do begin
    write(ans[i], ' ');
  end;
end.
 