/*
    Marko Bakovic
    Porez
*/

#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long int lld;

const int maxn = 1e5 + 5;

int n, k, days[ maxn ], value[ maxn ], price[ maxn ];

vector < int > adj[ maxn ];

void dfs( int curr )
{
    days[ curr ] = 0;
    price[ curr ] = value[ curr ];
    if ( adj[ curr ].empty() ) return;
    vector < int > S;
    lld sum = lld( value[ curr ] );
    for ( vector < int > :: iterator it = adj[ curr ].begin(); it != adj[ curr ].end(); it++ )
    {
        dfs( *it );
        days[ curr ] += days[ *it ];
        sum += lld( price[ *it ] );
        S.push_back( price[ *it ] );
    }
    if ( sum < lld( k ) )
    {
        price[ curr ] = int( sum );
        return;
    }
    if ( sum == lld( k ) )
    {
        price[ curr ] = 0;
        days[ curr ]++;
        return;
    }
    sum = lld( value[ curr ] );
    sort( S.begin(), S.end() );
    int cnt = 0;
    for ( int i = 0; i < S.size(); i++ )
    {
        if ( sum + lld( S[ i ] ) <= lld( k ) )
        {
            sum += lld( S[ i ] );
            cnt++;
            continue;
        }
        break;
    }
    days[ curr ] += S.size() - cnt;
    price[ curr ] = int( sum );
    if ( sum == lld( k ) )
    {
        price[ curr ] = 0;
        days[ curr ]++;
    }
}

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( "%d", &value[ i ] );
    for ( int i = 0; i < n - 1; i++ )
    {
        int x;
        scanf( "%d", &x );
        adj[ x - 1 ].push_back( i + 1 );
    }

    dfs( 0 );
    if ( price[ 0 ] ) days[ 0 ]++;

    printf( "%d\n", days[ 0 ] );

    return 0;
}
