import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k[] =new int[n];
		int a[][]=new int [n][m];
		for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		}
		scan.close();
		int cnt=0;
		int check[]=new int[m];
		for(int i=0;i<m;i++) {
			check[i]=0;
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		}
		for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		}
		System.out.println(cnt);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k[] =new int[n];
		int a[][]=new int [n][m];
		for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		}
		scan.close();
		int cnt=0;
		int check[]=new int[m];
		for(int i=0;i<m;i++) {
			check[i]=0;
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		}
		for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k[] =new int[n];
		int a[][]=new int [n][m];
		for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		}
		scan.close();
		int cnt=0;
		int check[]=new int[m];
		for(int i=0;i<m;i++) {
			check[i]=0;
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		}
		for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		}
		System.out.println(cnt);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k[] =new int[n];
		int a[][]=new int [n][m];
		for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		}
		scan.close();
		int cnt=0;
		int check[]=new int[m];
		for(int i=0;i<m;i++) {
			check[i]=0;
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		}
		for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		}
		System.out.println(cnt);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int k[] =new int[n]; k new int[n] n int a[][]=new int [n][m]; a new int [n][m] n m for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		} {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		} k[i]=scan.nextInt() k[i] k i scan.nextInt() scan.nextInt scan for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			} int j=0; int j=0; j 0 j<k[i] j k[i] k i j++ j++ j {
				a[i][j]=scan.nextInt();
			} {
				a[i][j]=scan.nextInt();
			} a[i][j]=scan.nextInt() a[i][j] a[i] a i j scan.nextInt() scan.nextInt scan scan.close() scan.close scan int cnt=0; cnt 0 int check[]=new int[m]; check new int[m] m for(int i=0;i<m;i++) {
			check[i]=0;
		} int i=0; int i=0; i 0 i<m i m i++ i++ i {
			check[i]=0;
		} {
			check[i]=0;
		} check[i]=0 check[i] check i 0 for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		} {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		} for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			} int j=0; int j=0; j 0 j<k[i] j k[i] k i j++ j++ j {
				int num=a[i][j]-1;
				check[num]+=1;
			} {
				int num=a[i][j]-1;
				check[num]+=1;
			} int num=a[i][j]-1; num a[i][j]-1 a[i][j] a[i] a i j 1 check[num]+=1 check[num] check num 1 for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		} int i=0; int i=0; i 0 i<m i m i++ i++ i {
			if(check[i] == n)cnt++;
		} {
			if(check[i] == n)cnt++;
		} if(check[i] == n)cnt++; check[i] == n check[i] check i n cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k[] =new int[n];
		int a[][]=new int [n][m];
		for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		}
		scan.close();
		int cnt=0;
		int check[]=new int[m];
		for(int i=0;i<m;i++) {
			check[i]=0;
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		}
		for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		}
		System.out.println(cnt);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k[] =new int[n];
		int a[][]=new int [n][m];
		for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		}
		scan.close();
		int cnt=0;
		int check[]=new int[m];
		for(int i=0;i<m;i++) {
			check[i]=0;
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		}
		for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		}
		System.out.println(cnt);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k[] =new int[n];
		int a[][]=new int [n][m];
		for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		}
		scan.close();
		int cnt=0;
		int check[]=new int[m];
		for(int i=0;i<m;i++) {
			check[i]=0;
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		}
		for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		}
		System.out.println(cnt);
	}
}