#include <iostream>
#include <cstdio>
#include <queue>

using namespace std;

int n;
int a[100005];
int otac[100005];
int rez=0;

struct cvor
{
    int rb;
    bool bio;
    int zb;
};
cvor zbir[100005];
int k;

bool operator<(cvor a1, cvor a2)
{
    return a1.zb>a2.zb;
}

priority_queue<cvor> h1;

struct node
{
    int data;
    node *next;
    node()
    {
        next=NULL;
        data=NULL;
    }
};

node *sinovi[100005];

int dodaj2(int index)
{
    int br=0;
    if(zbir[index].zb<=k)
    {
        int tmp1=zbir[index].rb;
        while(tmp1)
        {
            zbir[otac[tmp1]].zb-=zbir[tmp1].zb;
            tmp1=otac[tmp1];
        }
        return 1;
    }
    node *tmp=sinovi[index]->next;
    int mind=5000000;
    while(tmp)
    {
        br+=dodaj2(tmp->data);
        if(zbir[index].zb<=k) break;
        tmp=tmp->next;
    }
    //printf("BR: %i\n", br);
    return br;
}

void deletenode()
{
    int i;
    for(i=0; i<n; i++)
    {
        node*tmp;
        node*tmp2;
        tmp=sinovi[i];
        while(tmp)
        {
            tmp2=tmp;
            tmp=tmp->next;
            delete tmp2;
        }
    }
}

int main()
{
    int i;
    freopen("porez.in", "r", stdin);
    freopen("porez.out", "w", stdout);
    scanf("%i %i", &n, &k);
    for(i=0; i<n; i++)
    {
        sinovi[i]=new node;
        scanf("%i", &a[i]);
        zbir[i].zb=a[i];
        zbir[i].rb=i;
        zbir[i].bio=false;
    }
    for(i=1; i<n; i++)
    {
        scanf("%i", &otac[i]);
        otac[i]--;
        node*tmp=new node;
        tmp->data=i;
        tmp->next=sinovi[otac[i]]->next;
        sinovi[otac[i]]->next=tmp;
    }
    for(i=1; i<n; i++)
    {
        int tmp=i;
        while(tmp)
        {
            zbir[otac[tmp]].zb+=a[i];
            tmp=otac[tmp];
        }
    }
    //for(i=0; i<n; i++)
     //  printf("%i ", zbir[i].zb);
    //cout << endl;
    if(zbir[0].zb<=k)
    {
        printf("1\n");
        return 0;
    }
    for(i=1; i<n; i++)
    {
        if(zbir[i].zb<=k && zbir[i].zb+a[otac[zbir[i].rb]]>k)
        {
            zbir[i].bio=true;
            h1.push(zbir[i]);
            //printf("tz\n");
        }
    }
    cvor tmp;
    while(!h1.empty())
    {
        tmp=h1.top();
        if(tmp.rb==0)
        {
            rez++;
            printf("%i\n", rez);
            return 0;
        }
        h1.pop();
        int tmp1=tmp.rb;
        while(tmp1)
        {
            zbir[otac[tmp1]].zb-=zbir[tmp.rb].zb;
            if(zbir[tmp1].zb<=k && zbir[tmp1].zb+a[otac[zbir[tmp1].rb]]>k && !zbir[tmp1].bio)
            {
                zbir[tmp1].bio=true;
                h1.push(zbir[tmp1]);
            }
            tmp1=otac[tmp1];
        }
      //  for(i=0; i<n; i++)
       //     printf("%i ", zbir[i].zb);
        //cout << endl;
        rez++;
    }
    if(zbir[0].zb<=k)
    {
        rez++;
        //printf("blabla%i\n", rez);
        printf("%i\n", rez);
        return 0;
    }
   /* for(i=0; i<n; i++)
    {
        if(zbir[i].bio) printf("1 ");
        else printf("0 ");
    }*/
    rez+=1+dodaj2(0);
    printf("%i\n", rez);
    deletenode();
   // int index=0;
    //int min1=10000000;
    return 0;
}
/*
6 20
7 6 7 5 6 4
1 1 2 4 4

10 30
4 19 8 9 12 14 5 1 1 1
1 1 2 3 3 5 6 8 9

*/
