#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	int n,m;
	while(~scanf("%d %d",&n,&m)){
		vector<int> all;
		int in,num;
		map<int, int> my_map;
		for (int i = 0; i < n; ++i)
		{
			scanf("%d",&num);
			for (int j = 0; j < num; ++j)
			{
				scanf("%d",&in);
				if (my_map[in])
				{
					my_map[in]++;
				}
				else{
					my_map[in]=1;
					all.push_back(in);
				}
			}
		}
		int ans=0;
		for (int i = 0; i < all.size(); ++i)
		{
			if ( my_map[ all[i] ] ==n)
			{
				ans++;
			}
		}
		printf("%d\n",ans );

	}
	return 0;
}