import java.util.*;

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

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