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+1];
        int ans = 0;
        for(int i = 0;i < n;i++){
            int kind = sc.nextInt();
            for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            }
        }

        for(int i : like){
            if(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+1];
        int ans = 0;
        for(int i = 0;i < n;i++){
            int kind = sc.nextInt();
            for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            }
        }

        for(int i : like){
            if(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+1];
        int ans = 0;
        for(int i = 0;i < n;i++){
            int kind = sc.nextInt();
            for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            }
        }

        for(int i : like){
            if(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+1];
        int ans = 0;
        for(int i = 0;i < n;i++){
            int kind = sc.nextInt();
            for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            }
        }

        for(int i : like){
            if(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+1]; like new int[m+1] m+1 m 1 int ans = 0; ans 0 for(int i = 0;i < n;i++){
            int kind = sc.nextInt();
            for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int kind = sc.nextInt();
            for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            }
        } {
            int kind = sc.nextInt();
            for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            }
        } int kind = sc.nextInt(); kind sc.nextInt() sc.nextInt sc for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            } int j = 0; int j = 0; j 0 j < kind j kind j++ j++ j {
                like[sc.nextInt()]++;
            } {
                like[sc.nextInt()]++;
            } like[sc.nextInt()]++ like[sc.nextInt()] like sc.nextInt() sc.nextInt sc for(int i : like){
            if(i == n)
            ans++;
        } int i like {
            if(i == n)
            ans++;
        } {
            if(i == n)
            ans++;
        } if(i == n)
            ans++; i == n i n 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+1];
        int ans = 0;
        for(int i = 0;i < n;i++){
            int kind = sc.nextInt();
            for(int j = 0;j < kind;j++){
                like[sc.nextInt()]++;
            }
        }

        for(int i : like){
            if(i == n)
            ans++;
        }

        System.out.println(ans);
    }
}