#include <cstdio>
int n, m, k, a[35], s;
int main(){
	scanf("%d%d", &n, &m);
	for (register int i = 1; i <= n; ++i){
		scanf("%d", &k);
		for (register int j = 1, x; j <= k; ++j)
			scanf("%d", &x), ++a[x];
    }
	for (register int i = 1; i <= m; ++i) s += a[i] == n;
	printf("%d\n", s);
}
