#include <iostream>
using namespace std;

int main(){
	int N, M;
	cin >> N >> M;
	int log[30+1] = {0};
	int K, A;
	for(int n = 1; n <= N; n++){
		cin >> K;
		for(int i = 1; i <= K; i++){
			cin >> A;
			log[A]++;
		}
	}
	int res = 0;
	for(int i = 1; i <= M; i++){
		if(log[i] == N) res++;
	}
	cout << res << endl;
}
