import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int [] mArray = new int [m+1];
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			int [] aArray = new int [k];
			for(int j = 0; j < k; j++) {
				aArray[j] = sc.nextInt();
				mArray[aArray[j]]++;
			}
		}
		int result = 0;
		for(int i = 1; i < m+1; i++) {
			if(mArray[i] == n) result++;
		}
		System.out.println(result);
		sc.close();
	}

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

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

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int [] mArray = new int [m+1];
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			int [] aArray = new int [k];
			for(int j = 0; j < k; j++) {
				aArray[j] = sc.nextInt();
				mArray[aArray[j]]++;
			}
		}
		int result = 0;
		for(int i = 1; i < m+1; i++) {
			if(mArray[i] == n) result++;
		}
		System.out.println(result);
		sc.close();
	}

} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int [] mArray = new int [m+1];
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			int [] aArray = new int [k];
			for(int j = 0; j < k; j++) {
				aArray[j] = sc.nextInt();
				mArray[aArray[j]]++;
			}
		}
		int result = 0;
		for(int i = 1; i < m+1; i++) {
			if(mArray[i] == n) result++;
		}
		System.out.println(result);
		sc.close();
	}

}
