#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=2000010;
int n,m,ans,cnt;
int to[maxn],next[maxn],head[maxn],v[maxn],f[maxn],p[maxn];
int rd()
{
int ret=0,f=1; char gc=getchar();
while(gc<‘0‘||gc>‘9‘) {if(gc==‘-‘)f=-f; gc=getchar();}
while(gc>=‘0‘&&gc<=‘9‘) ret=ret*10+gc-‘0‘,gc=getchar();
return ret*f;
}
void add(int a,int b)
{
to[cnt]=b,next[cnt]=head[a],head[a]=cnt++;
}
bool cmp(int a,int b)
{
return f[a]<f[b];
}
void dfs(int x)
{
int i;
for(i=head[x];i!=-1;i=next[i]) dfs(to[i]);
for(p[0]=0,i=head[x];i!=-1;i=next[i]) p[++p[0]]=to[i];
sort(p+1,p+p[0]+1,cmp);
for(i=1;i<=p[0];i++) if(f[x]+f[p[i]]-1<=m) f[x]+=f[p[i]]-1,ans++;
}
int main()
{
n=rd(),m=rd();
int i,j,a,b;
memset(head,-1,sizeof(head));
for(i=1;i<=n;i++) v[i]=rd();
for(i=1;i<=n;i++)
{
a=rd(),f[i]=a+v[i];
for(j=1;j<=a;j++)
{
b=rd()+1;
add(i,b);
}
}
dfs(1);
printf("%d",ans);
return 0;
}