import 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 k[] = new int[n];
        int sum = 0;
        ArrayList<Integer> a = new ArrayList<>();
        int count = 0;
        for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        }
        if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        }
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k[] = new int[n];
        int sum = 0;
        ArrayList<Integer> a = new ArrayList<>();
        int count = 0;
        for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        }
        if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        }
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k[] = new int[n];
        int sum = 0;
        ArrayList<Integer> a = new ArrayList<>();
        int count = 0;
        for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        }
        if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        }
    } main {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k[] = new int[n];
        int sum = 0;
        ArrayList<Integer> a = new ArrayList<>();
        int count = 0;
        for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        }
        if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        }
    } 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 k[] = new int[n]; k new int[n] n int sum = 0; sum 0 ArrayList<Integer> a = new ArrayList<>(); a new ArrayList<>() int count = 0; count 0 for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        } {
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        } k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc sum += k[i] sum k[i] k i for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            } int j= 0; int j= 0; j 0 j < k[i] j k[i] k i j++ j++ j {
            	a.add(sc.nextInt());
            } {
            	a.add(sc.nextInt());
            } a.add(sc.nextInt()) a.add a sc.nextInt() sc.nextInt sc if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        } n == 1 n 1 {
        	System.out.println(k[0]);
        } System.out.println(k[0]) System.out.println System.out System System.out k[0] k 0 {
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        } for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            } int i = 1; int i = 1; i 1 i < m + 1 i m + 1 m 1 i++ i++ i {
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            } {
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            } int counta = 0; counta 0 for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                } int j = 0; int j = 0; j 0 j < sum j sum j++ j++ j {
                	if(i == a.get(j)){
                    	counta++;
                    }
                } {
                	if(i == a.get(j)){
                    	counta++;
                    }
                } if(i == a.get(j)){
                    	counta++;
                    } i == a.get(j) i a.get(j) a.get a j {
                    	counta++;
                    } counta++ counta if(counta == n){
                	count++;
                } counta == n counta n {
                	count++;
                } count++ count System.out.println(count) System.out.println System.out System System.out count 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 k[] = new int[n];
        int sum = 0;
        ArrayList<Integer> a = new ArrayList<>();
        int count = 0;
        for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        }
        if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        }
    }
} public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k[] = new int[n];
        int sum = 0;
        ArrayList<Integer> a = new ArrayList<>();
        int count = 0;
        for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        }
        if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        }
    }
} Main
import 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 k[] = new int[n];
        int sum = 0;
        ArrayList<Integer> a = new ArrayList<>();
        int count = 0;
        for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        }
        if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        }
    }
}