import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		}
		
		int flag[] = new int[M];
		for(int i = 0; i < M; i++) {
				flag[i] = 1;
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		}
		
		int flag[] = new int[M];
		for(int i = 0; i < M; i++) {
				flag[i] = 1;
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		}
		
		int flag[] = new int[M];
		for(int i = 0; i < M; i++) {
				flag[i] = 1;
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		}
		
		int flag[] = new int[M];
		for(int i = 0; i < M; i++) {
				flag[i] = 1;
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int K[] = new int[N]; K new int[N] N int A[][] = new int[N][M]; A new int[N][M] N M for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		} {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		} for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			} int j = 0; int j = 0; j 0 j < M j M j++ j++ j {
				A[i][j] = 0;
			} {
				A[i][j] = 0;
			} A[i][j] = 0 A[i][j] A[i] A i j 0 for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		} {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		} K[i] = sc.nextInt() K[i] K i sc.nextInt() sc.nextInt sc for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			} int j = 0; int j = 0; j 0 j < K[i] j K[i] K i j++ j++ j {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			} {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			} int temp = sc.nextInt() - 1; temp sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 A[i][temp] = 1 A[i][temp] A[i] A i temp 1 int flag[] = new int[M]; flag new int[M] M for(int i = 0; i < M; i++) {
				flag[i] = 1;
		} int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
				flag[i] = 1;
		} {
				flag[i] = 1;
		} flag[i] = 1 flag[i] flag i 1 for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		} {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		} for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			} int j = 0; int j = 0; j 0 j < M j M j++ j++ j {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			} {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			} if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				} A[i][j] != 1 A[i][j] A[i] A i j 1 {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				} flag[j] = 0 flag[j] flag j 0 int ans = 0; ans 0 for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
			if(flag[i] == 1) {
				ans++;
			}
		} {
			if(flag[i] == 1) {
				ans++;
			}
		} if(flag[i] == 1) {
				ans++;
			} flag[i] == 1 flag[i] flag i 1 {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		}
		
		int flag[] = new int[M];
		for(int i = 0; i < M; i++) {
				flag[i] = 1;
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		}
		
		int flag[] = new int[M];
		for(int i = 0; i < M; i++) {
				flag[i] = 1;
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		}
		
		int flag[] = new int[M];
		for(int i = 0; i < M; i++) {
				flag[i] = 1;
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}
