import java.util.*;
 
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        int number[] = new int[30];
 
        for(int i = 0;i<m;i++){
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        }
        int count = 0;
        for(int i = 0;i<n;i++){
            if(number[i] == m){
                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 m = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        int number[] = new int[30];
 
        for(int i = 0;i<m;i++){
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        }
        int count = 0;
        for(int i = 0;i<n;i++){
            if(number[i] == m){
                count++;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        int number[] = new int[30];
 
        for(int i = 0;i<m;i++){
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        }
        int count = 0;
        for(int i = 0;i<n;i++){
            if(number[i] == m){
                count++;
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        int number[] = new int[30];
 
        for(int i = 0;i<m;i++){
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        }
        int count = 0;
        for(int i = 0;i<n;i++){
            if(number[i] == m){
                count++;
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc int number[] = new int[30]; number new int[30] 30 for(int i = 0;i<m;i++){
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        } int i = 0; int i = 0; i 0 i<m i m i++ i++ i {
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        } {
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        } int tmp = sc.nextInt(); tmp sc.nextInt() sc.nextInt sc for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            } int j = 0; int j = 0; j 0 j<tmp j tmp j++ j++ j {
                number[sc.nextInt()-1]++;
            } {
                number[sc.nextInt()-1]++;
            } number[sc.nextInt()-1]++ number[sc.nextInt()-1] number sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 if(i != n-1){
                sc.nextLine();
            } i != n-1 i n-1 n 1 {
                sc.nextLine();
            } sc.nextLine() sc.nextLine sc int count = 0; count 0 for(int i = 0;i<n;i++){
            if(number[i] == m){
                count++;
            }
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            if(number[i] == m){
                count++;
            }
        } {
            if(number[i] == m){
                count++;
            }
        } if(number[i] == m){
                count++;
            } number[i] == m number[i] number i m {
                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 m = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        int number[] = new int[30];
 
        for(int i = 0;i<m;i++){
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        }
        int count = 0;
        for(int i = 0;i<n;i++){
            if(number[i] == m){
                count++;
            }
        }
        System.out.println(count);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        int number[] = new int[30];
 
        for(int i = 0;i<m;i++){
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        }
        int count = 0;
        for(int i = 0;i<n;i++){
            if(number[i] == m){
                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 m = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        int number[] = new int[30];
 
        for(int i = 0;i<m;i++){
            int tmp = sc.nextInt();
            for(int j = 0;j<tmp;j++){
                number[sc.nextInt()-1]++;
            }
            if(i != n-1){
                sc.nextLine();
            }
        }
        int count = 0;
        for(int i = 0;i<n;i++){
            if(number[i] == m){
                count++;
            }
        }
        System.out.println(count);
    }
}