#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
struct Node {
int val, i, j;
Node() : val(0), i(0), j(0) {}
Node(int i, int j) : val(0), i(i), j(j) {}
Node(int& val, int i, int& j) : val(val), i(i), j(j) {};
};
int main() {
int n, m; cin >> n >> m;
vector <int> w(n), c(n);
for (int i = 0; i < n; i++) {
cin >> w[i];
}
for (int i = 0; i < n; i++) {
cin >> c[i];
}
vector <vector<Node>> dp(n, vector<Node>(m + 1));
for (int i = 0; i < n; i++) {
dp[i][0] = Node(i, 0);
}
for (int j = 1; j <= m; j++) {
dp[0][j] = Node(0, j);
}
for (int i = 1; i < n; i++) {
for (int j = 1; j <= m; j++) {
int buf = dp[i - 1][j].val, jj = j;
if (j - w[i] >= 0 and dp[i - 1][j - w[i]].val + c[i] >= buf) {
buf = dp[i - 1][j - w[i]].val + c[i];
jj = j - w[i];
}
dp[i][j] = Node(buf, i - 1, jj);
}
}
vector <int> path;
int i = n - 1, j = m;
while (i > 0 and j > 0) {
Node buf = dp[i][j];
if (buf.i == i - 1 and buf.j != j) {
path.push_back(i + 1);
j = buf.j;
}
i = buf.i;
}
reverse(path.begin(), path.end());
cout << path.size() << endl;
for (auto c : path) {
cout << c << ' ';
}
return 0;
}
//отправляю, чтобы сохранить
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp1c2luZyBsbCA9IGxvbmcgbG9uZzsKCnN0cnVjdCBOb2RlIHsKICAgIGludCB2YWwsIGksIGo7CiAgICBOb2RlKCkgOiB2YWwoMCksIGkoMCksIGooMCkge30KICAgIE5vZGUoaW50IGksIGludCBqKSA6IHZhbCgwKSwgaShpKSwgaihqKSB7fQogICAgTm9kZShpbnQmIHZhbCwgaW50IGksIGludCYgaikgOiB2YWwodmFsKSwgaShpKSwgaihqKSB7fTsKfTsKCmludCBtYWluKCkgewogICAgaW50IG4sIG07IGNpbiA+PiBuID4+IG07CiAgICB2ZWN0b3IgPGludD4gdyhuKSwgYyhuKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgY2luID4+IHdbaV07CiAgICB9CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIGNpbiA+PiBjW2ldOwogICAgfQogICAgdmVjdG9yIDx2ZWN0b3I8Tm9kZT4+IGRwKG4sIHZlY3RvcjxOb2RlPihtICsgMSkpOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBkcFtpXVswXSA9IE5vZGUoaSwgMCk7CiAgICB9CiAgICBmb3IgKGludCBqID0gMTsgaiA8PSBtOyBqKyspIHsKICAgICAgICBkcFswXVtqXSA9IE5vZGUoMCwgaik7CiAgICB9CiAgICBmb3IgKGludCBpID0gMTsgaSA8IG47IGkrKykgewogICAgICAgIGZvciAoaW50IGogPSAxOyBqIDw9IG07IGorKykgewogICAgICAgICAgICBpbnQgYnVmID0gZHBbaSAtIDFdW2pdLnZhbCwgamogPSBqOwogICAgICAgICAgICBpZiAoaiAtIHdbaV0gPj0gMCBhbmQgZHBbaSAtIDFdW2ogLSB3W2ldXS52YWwgKyBjW2ldID49IGJ1ZikgewogICAgICAgICAgICAgICAgYnVmID0gZHBbaSAtIDFdW2ogLSB3W2ldXS52YWwgKyBjW2ldOwogICAgICAgICAgICAgICAgamogPSBqIC0gd1tpXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBkcFtpXVtqXSA9IE5vZGUoYnVmLCBpIC0gMSwgamopOwogICAgICAgIH0KICAgIH0KICAgIHZlY3RvciA8aW50PiBwYXRoOwogICAgaW50IGkgPSBuIC0gMSwgaiA9IG07CiAgICB3aGlsZSAoaSA+IDAgYW5kIGogPiAwKSB7CiAgICAgICAgTm9kZSBidWYgPSBkcFtpXVtqXTsKICAgICAgICBpZiAoYnVmLmkgPT0gaSAtIDEgYW5kIGJ1Zi5qICE9IGopIHsKICAgICAgICAgICAgcGF0aC5wdXNoX2JhY2soaSArIDEpOwogICAgICAgICAgICBqID0gYnVmLmo7CiAgICAgICAgfQogICAgICAgIGkgPSBidWYuaTsKICAgIH0KCiAgICByZXZlcnNlKHBhdGguYmVnaW4oKSwgcGF0aC5lbmQoKSk7CiAgICBjb3V0IDw8IHBhdGguc2l6ZSgpIDw8IGVuZGw7CiAgICBmb3IgKGF1dG8gYyA6IHBhdGgpIHsKICAgICAgICBjb3V0IDw8IGMgPDwgJyAnOwogICAgfQogICAgcmV0dXJuIDA7Cn0KCi8v0L7RgtC/0YDQsNCy0LvRj9GOLCDRh9GC0L7QsdGLINGB0L7RhdGA0LDQvdC40YLRjA==