import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		Set<Integer> intersection = new HashSet<Integer>();

		for(int i=0; i<m; i++){
			intersection.add(i+1);
		}

		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		}
		System.out.println(intersection.size());
	}
} import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		Set<Integer> intersection = new HashSet<Integer>();

		for(int i=0; i<m; i++){
			intersection.add(i+1);
		}

		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		}
		System.out.println(intersection.size());
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		Set<Integer> intersection = new HashSet<Integer>();

		for(int i=0; i<m; i++){
			intersection.add(i+1);
		}

		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		}
		System.out.println(intersection.size());
	} main {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		Set<Integer> intersection = new HashSet<Integer>();

		for(int i=0; i<m; i++){
			intersection.add(i+1);
		}

		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		}
		System.out.println(intersection.size());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Set<Integer> intersection = new HashSet<Integer>(); intersection new HashSet<Integer>() for(int i=0; i<m; i++){
			intersection.add(i+1);
		} int i=0; int i=0; i 0 i<m i m i++ i++ i {
			intersection.add(i+1);
		} {
			intersection.add(i+1);
		} intersection.add(i+1) intersection.add intersection i+1 i 1 for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		} {
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		} int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Set<Integer> set = new HashSet<Integer>(); set new HashSet<Integer>() for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			} int j=0; int j=0; j 0 j<k j k j++ j++ j {
				set.add(Integer.parseInt(sc.next()));
			} {
				set.add(Integer.parseInt(sc.next()));
			} set.add(Integer.parseInt(sc.next())) set.add set Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc intersection.retainAll(set) intersection.retainAll intersection set System.out.println(intersection.size()) System.out.println System.out System System.out intersection.size() intersection.size intersection String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		Set<Integer> intersection = new HashSet<Integer>();

		for(int i=0; i<m; i++){
			intersection.add(i+1);
		}

		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		}
		System.out.println(intersection.size());
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		Set<Integer> intersection = new HashSet<Integer>();

		for(int i=0; i<m; i++){
			intersection.add(i+1);
		}

		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		}
		System.out.println(intersection.size());
	}
} Main
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		Set<Integer> intersection = new HashSet<Integer>();

		for(int i=0; i<m; i++){
			intersection.add(i+1);
		}

		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		}
		System.out.println(intersection.size());
	}
}