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[][] data = new int[n][m];
		int[] ans = new int[m];
		int anscount = 0;

		for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		}

		for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		}

		for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		}


		System.out.println(anscount);
	}
} 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[][] data = new int[n][m];
		int[] ans = new int[m];
		int anscount = 0;

		for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		}

		for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		}

		for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		}


		System.out.println(anscount);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] data = new int[n][m];
		int[] ans = new int[m];
		int anscount = 0;

		for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		}

		for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		}

		for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		}


		System.out.println(anscount);
	} main {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] data = new int[n][m];
		int[] ans = new int[m];
		int anscount = 0;

		for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		}

		for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		}

		for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		}


		System.out.println(anscount);
	} 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[][] data = new int[n][m]; data new int[n][m] n m int[] ans = new int[m]; ans new int[m] m int anscount = 0; anscount 0 for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		} int i = 0; int i = 0; i 0 i<m i m i++ i++ i {
			ans[i]= i+1;
		} {
			ans[i]= i+1;
		} ans[i]= i+1 ans[i] ans i i+1 i 1 for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		} int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		} {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			} int j = 0; int j = 0; j 0 j<k j k j++ j++ j {
				data[i][j] = sc.nextInt();
			} {
				data[i][j] = sc.nextInt();
			} data[i][j] = sc.nextInt() data[i][j] data[i] data i j sc.nextInt() sc.nextInt sc for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		} int k = 0; int k = 0; k 0 k<m k m k++ k++ k {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		} {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		} int count = 0; count 0 for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			} int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			} {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			} for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				} int j = 0; int j = 0; j 0 j<m j m j++ j++ j {
					if (data[i][j]==ans[k]) {
						count++;
					}
				} {
					if (data[i][j]==ans[k]) {
						count++;
					}
				} if (data[i][j]==ans[k]) {
						count++;
					} data[i][j]==ans[k] data[i][j] data[i] data i j ans[k] ans k {
						count++;
					} count++ count if (count==n) {
				anscount++;
			} count==n count n {
				anscount++;
			} anscount++ anscount System.out.println(anscount) System.out.println System.out System System.out anscount 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[][] data = new int[n][m];
		int[] ans = new int[m];
		int anscount = 0;

		for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		}

		for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		}

		for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		}


		System.out.println(anscount);
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] data = new int[n][m];
		int[] ans = new int[m];
		int anscount = 0;

		for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		}

		for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		}

		for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		}


		System.out.println(anscount);
	}
} 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[][] data = new int[n][m];
		int[] ans = new int[m];
		int anscount = 0;

		for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		}

		for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		}

		for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		}


		System.out.println(anscount);
	}
}
