#include <iostream>
#include <set>
#include <utility>

using namespace std;

typedef unsigned long long llu;

static llu t;
static unsigned n, ocene[100001];
static set<pair<unsigned, llu>> putevi[100001];
static pair<unsigned, llu> reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee[100001];

static inline resi(unsigned i, llu t)
{
    return ocene[i];
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> t;
    for (unsigned i = 1; i <= n; i++)
        cin >> ocene[i];
    for (unsigned i = 1; i <= n; i++)
        cin >> reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee[i].first;
    for (unsigned i = 1; i <= n; i++)
        cin >> reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee[i].second;
    for (unsigned i = 1; i <= n; i++)
        putevi[reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee[i].first].insert(make_pair(i, reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee[i].second));

    llu m = 0;
    for (unsigned i = 1; i <= n; i++)
    {
        llu res = resi(i, t);
        if (res > m)
            m = res;
    }
    cout << m;
    return 0;
}