/*
    Aleksandar "Al3kSaNdaR" Ivanovic

    porez
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef long long int lld;

const int MaxN = 100000 + 5;

int N, DepthLeaves, A[MaxN], Level[MaxN], Parent[MaxN];
bool Mark[MaxN], Visited[MaxN];

lld K, V[MaxN], Sum[MaxN];

vector < int > E[MaxN], Nodes[MaxN];

inline void BFS ( int Start )
{
    queue < int > Q;

    Q.push ( Start );

    Visited[Start] = true;
    Parent[Start] = -1;

    while ( ! Q.empty ( ) )
    {
        int Curr = Q.front ( );

        Q.pop ( );

        for ( vector < int > :: iterator it = E[Curr].begin ( ); it != E[Curr].end ( ); it++ )
        {
            int Next = * it;

            if ( Visited[Next] ) continue;

            Q.push ( Next );

            Visited[Next] = true;
            Parent[Next] = Curr;
            Level[Next] = Level[Curr] + 1;

            if ( Level[Next] > DepthLeaves ) DepthLeaves = Level[Next];
        }
    }
}

inline void BFSMark ( int Start )
{
    queue < int > Q;

    Q.push ( Start );

    Mark[Start] = true;

    while ( ! Q.empty ( ) )
    {
        int Curr = Q.front ( );

        Q.pop ( );

        for ( vector < int > :: iterator it = E[Start].begin ( ); it != E[Start].end ( ); it++ )
        {
            int Next = * it;

            if ( Mark[Next] ) continue;

            if ( Next < Start ) continue;

            Mark[Next] = true;

            Q.push ( Next );
        }
    }
}

inline bool Compare ( const int &A, const int &B )
{
    return Sum[A] > Sum[B];
}

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

    scanf ( "%d %lld", &N, &K );

    for ( int i = 0; i < N; i++ ) scanf ( "%lld", &V[i] );

    for ( int i = 0; i < N - 1; i++ )
    {
        int idx;

        scanf ( "%d", &idx );

        idx--;

        E[idx].push_back ( i + 1 );
        E[i + 1].push_back ( idx );
    }

    BFS ( 0 );

    for ( int i = 0; i < N; i++ ) Nodes[Level[i]].push_back ( i );

    for ( int i = 0; i < N; i++ ) Sum[i] = V[i];

    for ( int i = DepthLeaves; i >= 0; i-- )
    {
        for ( vector < int > :: iterator it = Nodes[i].begin ( ); it != Nodes[i].end ( ); it++ )
        {
            int Prev = Parent[* it];

            if ( Prev != -1 ) Sum[Prev] += Sum[* it];
        }
    }

    memset ( Mark, false, sizeof ( Mark ) );

    int Sol = 0;

    for ( int i = DepthLeaves; i >= 0; i-- )
    {
        sort ( Nodes[i].begin ( ), Nodes[i].end ( ), Compare );

        for ( vector < int > :: iterator it = Nodes[i].begin ( ); it != Nodes[i].end ( ); it++ )
        {
            int Curr = * it, Next = -1;

            if ( Mark[Curr] ) continue;

            Sol++;

            while ( ( Curr != -1 ) && ( Sum[Curr] <= K ) )
            {
                Mark[Curr] = true;

                BFSMark ( Curr );

                Next = Curr;
                Curr = Parent[Curr];
            }

            if ( Curr == -1 )
            {
                printf ( "%d\n", Sol );

                return 0;
            }

            do
            {
                Sum[Curr] -= Sum[Next];

                Curr = Parent[Curr];
            }
            while ( Curr != -1 );
        }
    }

    printf ( "%d\n", Sol );

    return 0;
}
