#include <bits/stdc++.h>

#define all(v) begin(v), end(v)
#define fi first
#define se second
#define dbg(x) "[" #x " = " << x << "]"

#define left __left
#define right __right

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)

using namespace std;

bool M1;
const int infINT = 1e9 + 123;
const long long inf = 1e18 + 123;

typedef pair<int, int > ii;
typedef pair<long long, int > lli;

const int MAXN = MASK(19) + 10;

int numVal, val[MAXN];
long long numLim, cost[MAXN];
pair<long long, int > tot[MAXN];
bool choose[MAXN];

void input(){
    cin >> numVal >> numLim;
    for(int i = 1; i <= numVal; i++) cin >> val[i];
    for(int i = 1; i <= numVal; i++) cin >> cost[i];
}

bool check(const int &m){
    for(int i = 1; i <= numVal; i++){
        if (max(0, (m - val[i])) <= numLim / cost[i])
            tot[i].fi = 1LL * max(0, (m - val[i])) * cost[i];
        else
            tot[i].fi = numLim + 1;
        tot[i].se = i;
    }

    if (m < numVal) nth_element(tot + 1, tot + 1 + m, tot + 1 + numVal);

    long long sum = 0;
    for(int i = 1; i <= m; i++){
        if (sum > numLim - tot[i].fi) return 0;
        sum += tot[i].fi;
    }

    for(int i = 1; i <= numVal; i++){
        choose[tot[i].se] = (i <= m);
    }

    return 1;
}

void solve(){
    int l = 1, r = numVal, res = 0, m;
    while(l <= r){
        m = (l + r) >> 1;
        if (check(m)) res = m, l = m + 1;
        else r = m - 1;
    }
    cout << res << '\n';
    for(int i = 1; i <= numVal; i++){
        cout << (choose[i] ? max(res, val[i]): val[i]) - val[i] << ' ';
    }
}

bool M2;
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define task "hindex"
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    input();
    solve();
    cerr << (1.0 * clock()) / CLOCKS_PER_SEC << ".s\n";
    cerr << (&M2 - &M1) / 1048576 << " mb\n";
}