#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define N 2000010
using namespace std;
int sum,m,ans,n,T,p;
int head[N],next[N],to[N];
int a[N],c[N];
int getint()
{
int res=0,w=1;
char ch=getchar();
while ((ch>‘9‘ || ch<‘0‘)&&ch!=‘-‘) ch=getchar();
if (ch==‘-‘) w=-1,ch=getchar();
while (ch>=‘0‘&&ch<=‘9‘) res=res*10+ch-‘0‘,ch=getchar();
return res*w;
}
void link(int x,int y) {next[++sum]=head[x]; head[x]=sum; to[sum]=y;}
void dfs(int p)
{
for (int i=head[p];i;i=next[i]) dfs(to[i]);
int k=0;
for (int i=head[p];i;i=next[i]) a[++k]=c[to[i]];
sort(a+1,a+1+k);
for (int i=1;i<=k;i++)
{
if (c[p]+a[i]-1<=m)
c[p]+=a[i]-1,ans++;
else break;
}
}
int main()
{
n=getint(); m=getint();
for (int i=1;i<=n;i++) c[i]=getint();
for (int i=1;i<=n;i++)
{
T=getint(); c[i]+=T;
while (T--) {p=getint()+1; link(i,p); }
}
dfs(1);
printf("%d\n",ans);
return 0;
}