import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m =sc.nextInt();
		int k, a;
		int food[][] = new int[n][m + 1];
		for(int i = 0; i < n; ++i) {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		}
		sc.close();
		int ans = 0;
		int j = 0;
		for(int i = 1; i <= m; ++i) {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == 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 = sc.nextInt(), m =sc.nextInt();
		int k, a;
		int food[][] = new int[n][m + 1];
		for(int i = 0; i < n; ++i) {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		}
		sc.close();
		int ans = 0;
		int j = 0;
		for(int i = 1; i <= m; ++i) {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == n)++ans;
		}
		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m =sc.nextInt();
		int k, a;
		int food[][] = new int[n][m + 1];
		for(int i = 0; i < n; ++i) {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		}
		sc.close();
		int ans = 0;
		int j = 0;
		for(int i = 1; i <= m; ++i) {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == n)++ans;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m =sc.nextInt();
		int k, a;
		int food[][] = new int[n][m + 1];
		for(int i = 0; i < n; ++i) {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		}
		sc.close();
		int ans = 0;
		int j = 0;
		for(int i = 1; i <= m; ++i) {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == n)++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 m =sc.nextInt(); m sc.nextInt() sc.nextInt sc int k k a; a int food[][] = new int[n][m + 1]; food new int[n][m + 1] n m + 1 m 1 for(int i = 0; i < n; ++i) {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		} int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		} {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		} k = sc.nextInt() k sc.nextInt() sc.nextInt sc for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			} int j = 0; int j = 0; j 0 j < k j k ++j ++j j {
				a = sc.nextInt();
				food[i][a]++;
			} {
				a = sc.nextInt();
				food[i][a]++;
			} a = sc.nextInt() a sc.nextInt() sc.nextInt sc food[i][a]++ food[i][a] food[i] food i a sc.close() sc.close sc int ans = 0; ans 0 int j = 0; j 0 for(int i = 1; i <= m; ++i) {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == n)++ans;
		} int i = 1; int i = 1; i 1 i <= m i m ++i ++i i {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == n)++ans;
		} {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == n)++ans;
		} for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			} j = 0; j = 0 j 0 j < n j n ++j ++j j {
				if(food[j][i] == 0)break;
			} {
				if(food[j][i] == 0)break;
			} if(food[j][i] == 0)break; food[j][i] == 0 food[j][i] food[j] food j i 0 break; if(j == n)++ans; j == n j n ++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(), m =sc.nextInt();
		int k, a;
		int food[][] = new int[n][m + 1];
		for(int i = 0; i < n; ++i) {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		}
		sc.close();
		int ans = 0;
		int j = 0;
		for(int i = 1; i <= m; ++i) {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == n)++ans;
		}
		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m =sc.nextInt();
		int k, a;
		int food[][] = new int[n][m + 1];
		for(int i = 0; i < n; ++i) {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		}
		sc.close();
		int ans = 0;
		int j = 0;
		for(int i = 1; i <= m; ++i) {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == 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 = sc.nextInt(), m =sc.nextInt();
		int k, a;
		int food[][] = new int[n][m + 1];
		for(int i = 0; i < n; ++i) {
			k = sc.nextInt();
			for(int j = 0; j < k; ++j) {
				a = sc.nextInt();
				food[i][a]++;
			}
		}
		sc.close();
		int ans = 0;
		int j = 0;
		for(int i = 1; i <= m; ++i) {
			for(j = 0; j < n; ++j) {
				if(food[j][i] == 0)break;
			}
			if(j == n)++ans;
		}
		System.out.println(ans);
	}

}
