import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		int food[] = new int[M];
		int a[] = new int[M];
		for (int i = 0; i < M; i++) {
			food[i] = i + 1;
			a[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		}
		sc.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (a[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		int food[] = new int[M];
		int a[] = new int[M];
		for (int i = 0; i < M; i++) {
			food[i] = i + 1;
			a[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		}
		sc.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (a[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		int food[] = new int[M];
		int a[] = new int[M];
		for (int i = 0; i < M; i++) {
			food[i] = i + 1;
			a[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		}
		sc.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (a[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		int food[] = new int[M];
		int a[] = new int[M];
		for (int i = 0; i < M; i++) {
			food[i] = i + 1;
			a[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		}
		sc.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (a[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N N M; M N = sc.nextInt() N sc.nextInt() sc.nextInt sc 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 int food[] = new int[M]; food new int[M] M int a[] = new int[M]; a new int[M] M for (int i = 0; i < M; i++) {
			food[i] = i + 1;
			a[i] = 0;
		} int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
			food[i] = i + 1;
			a[i] = 0;
		} {
			food[i] = i + 1;
			a[i] = 0;
		} food[i] = i + 1 food[i] food i i + 1 i 1 a[i] = 0 a[i] a i 0 for (int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		} 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++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		} {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		} K[i] = sc.nextInt() K[i] K i sc.nextInt() sc.nextInt sc for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			} int j = 0; int j = 0; j 0 j < K[i] j K[i] K i j++ j++ j {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			} {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			} A[i][j] = sc.nextInt() A[i][j] A[i] A i j sc.nextInt() sc.nextInt sc for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				} int k = 0; int k = 0; k 0 k < M k M k++ k++ k {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				} {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				} if (A[i][j] == food[k]) {
						a[k]++;
					} A[i][j] == food[k] A[i][j] A[i] A i j food[k] food k {
						a[k]++;
					} a[k]++ a[k] a k sc.close() sc.close sc int ans = 0; ans 0 for (int i = 0; i < M; i++) {
			if (a[i] == N) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
			if (a[i] == N) {
				ans++;
			}
		} {
			if (a[i] == N) {
				ans++;
			}
		} if (a[i] == N) {
				ans++;
			} a[i] == N a[i] a i N {
				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, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		int food[] = new int[M];
		int a[] = new int[M];
		for (int i = 0; i < M; i++) {
			food[i] = i + 1;
			a[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		}
		sc.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (a[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		int food[] = new int[M];
		int a[] = new int[M];
		for (int i = 0; i < M; i++) {
			food[i] = i + 1;
			a[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		}
		sc.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (a[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		int food[] = new int[M];
		int a[] = new int[M];
		for (int i = 0; i < M; i++) {
			food[i] = i + 1;
			a[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for (int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for (int k = 0; k < M; k++) {
					if (A[i][j] == food[k]) {
						a[k]++;
					}
				}

			}
		}
		sc.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (a[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}
