#include <iostream>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

#define ll long long
#define MaxN 100010

int n, k;
ll val[MaxN];
int father[MaxN];

int u[MaxN];
int v[MaxN];
int prev[MaxN];
int last[MaxN];

ll s[MaxN];
int d[MaxN];
priority_queue<int> heap;

void Solve( int node )
{
    //printf("Solve %d\n",node+1);
    d[node] = 0;

    for (int p = last[node]; p != -1; p = prev[p]) {
        int node2 = v[p];
        Solve( node2 );
        d[node] += d[node2];
    }

    while ( !heap.empty() ) heap.pop();

    ll sumHeap = val[node];
    for (int p = last[node]; p != -1; p = prev[p]) {
        int node2 = v[p];

        if ( sumHeap + s[node2] <= k ) {
            heap.push( s[node2] );
            sumHeap += s[node2];
        }
        else {

            if ( !heap.empty() ) {
                int p = heap.top();
                if ( p > s[node2] ) {
                    heap.pop();
                    heap.push( s[node2] );

                    sumHeap -= p;
                    sumHeap += s[node2];
                }
            }
            d[node]++;
        }

        //printf("%d %d | %d %d\n",node+1,node2+1,d[node],sumHeap);
    }

    if ( sumHeap < k ) s[node] = sumHeap;
    else               { s[node] = 0LL; d[node]++; }

    //printf("%d => %d %lld\n",node+1,d[node],s[node]);
}

int main() {
    freopen("porez.in","r",stdin);
    freopen("porez.out","w",stdout);

    scanf("%d%d",&n,&k);
    for (int i = 0; i < n; ++i) {
        scanf("%lld",&val[i]);
    }

    memset(last, -1, sizeof(last));
    for (int i = 1; i < n; ++i) {
        scanf("%d",&father[i]);
        father[i]--;

        u[i] = father[i];
        v[i] = i;
        prev[i] = last[ u[i] ];
        last[ u[i] ] = i;
    }

    Solve(0);
    printf("%d\n",d[0]+(s[0]!=0));

    return 0;
}
