#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>

using namespace std;

struct Poslovnica
{
    unsigned long long cP;
    int vPos;
    vector<int> dPos;
    int _nU;
    int pPtz;
    unsigned long long rOst;
};

Poslovnica p[100000];
int n;
unsigned long long k;
unsigned long long tOst[100000];

int main(int argc, char *argv[])
{
    FILE* f;
    f = fopen("porez.in", "r");
    fscanf(f, "%d", &n);
    fscanf(f, "%llu", &k);
    for (int i = 0; i < n; ++i) fscanf(f, "%llu", &p[i].cP);
    p[0].vPos = -1;
    for (int i = 1; i < n; ++i)
    {
        int _v;
        fscanf(f, "%d", &_v);
        --_v;
        p[i].vPos = _v;
        p[_v].dPos.push_back(i);
    }
    fclose(f);
    queue<int> q;
    for (int i = 0; i < n; ++i)
    {
        p[i]._nU = 0;
        if (p[i].dPos.size() < 1)
        {
            p[i].pPtz = 1;
            p[i].rOst = p[i].cP;
            q.push(p[i].vPos);
        }
    }
    while (!q.empty())
    {
        int _cUpd = q.front();
        q.pop();
        ++p[_cUpd]._nU;
        if (p[_cUpd]._nU == p[_cUpd].dPos.size())
        {
            int _rPP = 0;
            int _brO = p[_cUpd].dPos.size() + 1;
            for (int i = 0; i < _brO - 1; ++i)
            {
                _rPP += (p[p[_cUpd].dPos[i]].pPtz - 1);
                tOst[i] = p[p[_cUpd].dPos[i]].rOst;
            }
            tOst[_brO - 1] = p[_cUpd].cP;
            sort(&tOst[0], &tOst[_brO]);
            int _cP = 0;
            int _cI = 0;
            int _tE = _brO - 1;
            unsigned long long pO;
            while (_cI <= _tE)
            {
                ++_cP;
                pO = tOst[_tE];
                while (_cI < _tE && pO + tOst[_cI] <= k) pO += tOst[_cI++];
                _tE--;
            }
            p[_cUpd].pPtz = _rPP + _cP;
            p[_cUpd].rOst = pO;
            if (p[_cUpd].vPos > -1) q.push(p[_cUpd].vPos);
        }
    }
    f = fopen("porez.out", "w");
    fprintf(f, "%d", p[0].pPtz);
    fclose(f);
    return EXIT_SUCCESS;
}
