#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,m;
	int array;
	while(cin>>n>>m)
	{
		
		vector <int> list[n];
		int i=0;
		
		while(cin>>array)//read column
		{
			list[i].push_back(array);
			if((list[i].size()-1)==list[i].at(0))
			{
				i++;
			}
		}
		int calculation[2][m];
		for(unsigned int i=0;i<m;i++)
		{
			calculation[0][i]=i+1;
			calculation[1][i]=0;
		}
		for(unsigned int i=0;i<n;i++)
		{
			for(unsigned int j=1;j<=list[i].at(0);j++)
			{
				calculation[1][(list[i].at(j))-1]++;

			}
		}
		int sum=0;
		for(unsigned int i=0;i<m;i++)
		{
			
			if(calculation[1][i] == n)
			{
				sum++;
			}
		}
		cout<<sum;
	}
}