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