import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int[] like = new int[M];
	for(int i = 0; i<N; i++) {
	    int k = sc.nextInt();
	    for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    }
	}
	int ans = 0;
	for(int i = 0; i<M; i++) {
	    if(like[i] == N) {
		ans++;
	    }
        }
	System.out.println(ans);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int[] like = new int[M];
	for(int i = 0; i<N; i++) {
	    int k = sc.nextInt();
	    for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    }
	}
	int ans = 0;
	for(int i = 0; i<M; i++) {
	    if(like[i] == N) {
		ans++;
	    }
        }
	System.out.println(ans);
    }
} Main public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int[] like = new int[M];
	for(int i = 0; i<N; i++) {
	    int k = sc.nextInt();
	    for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    }
	}
	int ans = 0;
	for(int i = 0; i<M; i++) {
	    if(like[i] == N) {
		ans++;
	    }
        }
	System.out.println(ans);
    } main {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int[] like = new int[M];
	for(int i = 0; i<N; i++) {
	    int k = sc.nextInt();
	    for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    }
	}
	int ans = 0;
	for(int i = 0; i<M; i++) {
	    if(like[i] == 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 int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int[] like = new int[M]; like new int[M] M for(int i = 0; i<N; i++) {
	    int k = sc.nextInt();
	    for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    }
	} int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
	    int k = sc.nextInt();
	    for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    }
	} {
	    int k = sc.nextInt();
	    for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    }
	} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    } int j = 0; int j = 0; j 0 j<k j k j++ j++ j {
		like[sc.nextInt()-1]++;
	    } {
		like[sc.nextInt()-1]++;
	    } like[sc.nextInt()-1]++ like[sc.nextInt()-1] like sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 int ans = 0; ans 0 for(int i = 0; i<M; i++) {
	    if(like[i] == N) {
		ans++;
	    }
        } int i = 0; int i = 0; i 0 i<M i M i++ i++ i {
	    if(like[i] == N) {
		ans++;
	    }
        } {
	    if(like[i] == N) {
		ans++;
	    }
        } if(like[i] == N) {
		ans++;
	    } like[i] == N like[i] like i N {
		ans++;
	    } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int[] like = new int[M];
	for(int i = 0; i<N; i++) {
	    int k = sc.nextInt();
	    for(int j = 0; j<k; j++) {
		like[sc.nextInt()-1]++;
	    }
	}
	int ans = 0;
	for(int i = 0; i<M; i++) {
	    if(like[i] == N) {
		ans++;
	    }
        }
	System.out.println(ans);
    }
}