#include <iostream>
#include <cstring>
using namespace std;


int arr[10000000];
int main(void)
{
	int n, m;

	while(cin >> n >> m)
	{
		
		int counter = 0;

		memset(arr, 0, sizeof(arr));

		for(int i = 0; i < n; i++)
		{
			int num;	cin >> num;

			for(int j = 0; j < num; j++)
			{
				int tmp;	cin >> tmp;
				arr[tmp]++;

				if(arr[tmp] == n)
					counter++;
			}
		}

		cout << counter << '\n';
	}
	return 0;
}