#include <bits/stdc++.h>
using namespace std;
int n, v;
struct Tri {
  int t, p, index;
  bool operator<(const Tri &x) const {
    if (t != x.t)
      return t < x.t;
    else if (t == 1)
      return p < x.p;
    else
      return p > x.p;
  }
} tri[1048576];
int main() {
  int i, j, sot, sop, max, imax = max = 0;
  scanf("%d%d", &n, &v);
  for (i = 0; i < n; ++i) {
    scanf("%d%d", &tri[i].t, &tri[i].p);
    tri[i].index = i + 1;
  }
  sort(tri, tri + n);
  for (sop = sot = i = j = 0; j < n; ++j) {
    sot += tri[j].t;
    sop += tri[j].p;
    while (sot > v) {
      sot -= tri[i].t;
      sop -= tri[i].p;
      ++i;
    }
    if (sop > max) {
      max = sop;
      imax = i;
    }
  }
  printf("%d\n", max);
  for (sop = sot = 0, j = i = imax; j < n; ++j) {
    sot += tri[j].t;
    sop += tri[j].p;
    if (sot > v) break;
    printf(" %d" + (i == j), tri[j].index);
  }
  printf("\n");
  return 0;
}
