#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int P1[100005],P2[100005],PA[100005],O[200005],C[100005],N,Sol;
long long Vr[100005],K;

void ucitajisredi(){
   int i,j;
   scanf("%d%d",&N,&K);
   for (i=1; i<=N; i++) scanf("%lld",Vr+i);
   for (i=1; i<N; i++){
      P1[i] = i+1;
      scanf("%d",P2+i);
      C[P1[i]]++;
      C[P2[i]]++;
   }
   PA[1] = 1;
   for (i=2; i<=N+1; i++) PA[i] = PA[i-1] + C[i-1];
   memset(C,0,sizeof(C));
   for (i=1; i<N; i++){
      O[C[P1[i]]+PA[P1[i]]] = P2[i];
      O[C[P2[i]]+PA[P2[i]]] = P1[i];
      C[P1[i]]++;
      C[P2[i]]++;
   }
}

struct djete{
   int idx;
   long long vr;
};

bool cmp(djete a,djete b){
   return a.vr < b.vr;
}

djete Djeca[100005];

void dfsjechudo(int x,int odakle){
   int i,j,k;
   long long s;
   for (i=PA[x]; i<PA[x+1]; i++) if (O[i]!=odakle) dfsjechudo(O[i],x);
   k=0;
   for (i=PA[x]; i<PA[x+1]; i++) if (O[i]!=odakle){
      k++;
      Djeca[k].idx = O[i];
      Djeca[k].vr = Vr[O[i]];
   }
   sort(Djeca+1,Djeca+k+1,cmp);
   j=0;
   s = Vr[x];
   for (i=1; i<=k; i++){
      if (s+Vr[Djeca[i].idx] <= K){
         s+=Vr[Djeca[i].idx];
         j++;
      } else break;
   }
   Vr[x] = s;
   Sol += k-j;
   //printf("zavrsavam %d dodajem %d\n",x,k-j);
}

int main(){
   freopen("porez.in","r",stdin);
   freopen("porez.out","w",stdout);
   ucitajisredi();
   Sol=1;
   dfsjechudo(1,1);
   printf("%d\n",Sol);
   return 0;
}


