import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] favs = new int[m];
		int answer = 0;
		for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] favs = new int[m];
		int answer = 0;
		for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	}
} Main public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	} main {
		new Main().solve(new Scanner(System.in));
	} new Main().solve(new Scanner(System.in)) new Main().solve new Main() new Scanner(System.in) String[] args args public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] favs = new int[m];
		int answer = 0;
		for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	} solve {
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] favs = new int[m];
		int answer = 0;
		for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	} 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 int[] favs = new int[m]; favs new int[m] m int answer = 0; answer 0 for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		} {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		} int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			} int j=0; int j=0; j 0 j<k j k j++ j++ j {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			} {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			} int fav = Integer.parseInt(sc.next()); fav Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc favs[fav-1]++ favs[fav-1] favs fav-1 fav 1 if(favs[fav-1] >= n) {
					answer++;
				} favs[fav-1] >= n favs[fav-1] favs fav-1 fav 1 n {
					answer++;
				} answer++ answer System.out.println(answer) System.out.println System.out System System.out answer Scanner sc sc public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] favs = new int[m];
		int answer = 0;
		for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	}
} public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] favs = new int[m];
		int answer = 0;
		for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] favs = new int[m];
		int answer = 0;
		for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	}
}
