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[] a = new int[31];
        int cnt = 0;

        for(int i = 0;i<n;i++){
            a[i] = 0;
        }


        for(int i = 0;i<n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        }

        for(int i =0;i<31;i++){
            if(a[i]==n){
            cnt++;
            }
        }

        System.out.println(cnt);

    }
} 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[] a = new int[31];
        int cnt = 0;

        for(int i = 0;i<n;i++){
            a[i] = 0;
        }


        for(int i = 0;i<n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        }

        for(int i =0;i<31;i++){
            if(a[i]==n){
            cnt++;
            }
        }

        System.out.println(cnt);

    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[31];
        int cnt = 0;

        for(int i = 0;i<n;i++){
            a[i] = 0;
        }


        for(int i = 0;i<n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        }

        for(int i =0;i<31;i++){
            if(a[i]==n){
            cnt++;
            }
        }

        System.out.println(cnt);

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[31];
        int cnt = 0;

        for(int i = 0;i<n;i++){
            a[i] = 0;
        }


        for(int i = 0;i<n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        }

        for(int i =0;i<31;i++){
            if(a[i]==n){
            cnt++;
            }
        }

        System.out.println(cnt);

    } 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[] a = new int[31]; a new int[31] 31 int cnt = 0; cnt 0 for(int i = 0;i<n;i++){
            a[i] = 0;
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            a[i] = 0;
        } {
            a[i] = 0;
        } a[i] = 0 a[i] a i 0 for(int i = 0;i<n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        } 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++){
                int num = sc.nextInt();
                a[num]++;               
            }
        } {
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            } int j = 0; int j = 0; j 0 j<k j k j++ j++ j {
                int num = sc.nextInt();
                a[num]++;               
            } {
                int num = sc.nextInt();
                a[num]++;               
            } int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc a[num]++ a[num] a num for(int i =0;i<31;i++){
            if(a[i]==n){
            cnt++;
            }
        } int i =0; int i =0; i 0 i<31 i 31 i++ i++ i {
            if(a[i]==n){
            cnt++;
            }
        } {
            if(a[i]==n){
            cnt++;
            }
        } if(a[i]==n){
            cnt++;
            } a[i]==n a[i] a i n {
            cnt++;
            } 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 sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[31];
        int cnt = 0;

        for(int i = 0;i<n;i++){
            a[i] = 0;
        }


        for(int i = 0;i<n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        }

        for(int i =0;i<31;i++){
            if(a[i]==n){
            cnt++;
            }
        }

        System.out.println(cnt);

    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[31];
        int cnt = 0;

        for(int i = 0;i<n;i++){
            a[i] = 0;
        }


        for(int i = 0;i<n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        }

        for(int i =0;i<31;i++){
            if(a[i]==n){
            cnt++;
            }
        }

        System.out.println(cnt);

    }
} 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[] a = new int[31];
        int cnt = 0;

        for(int i = 0;i<n;i++){
            a[i] = 0;
        }


        for(int i = 0;i<n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                int num = sc.nextInt();
                a[num]++;               
            }
        }

        for(int i =0;i<31;i++){
            if(a[i]==n){
            cnt++;
            }
        }

        System.out.println(cnt);

    }
}
