import java.util.*;
import java.io.*;

import static java.lang.System.in;

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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n= sc.nextInt(), m =sc.nextInt();
        int[] rec = new int[m+1];
        for(int i=0;i<n;i++){
            int k = sc.nextInt();
            for(int j=0;j<k;j++){
                int a = sc.nextInt();
                rec[a] += 1;
            }
        }
        int ans=0;
        for(int i=1;i<=m;i++) {
            if(rec[i]==n) ans++;
        }
        System.out.println(ans);
    }
}
