/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int variety = sc.nextInt();
        int[] k = new int[n];
        int[] preference = new int[variety];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        }
        for (int i = 0; i < variety; i++) {
            if (preference[i] == n) {
                ans++;
            } 
        }
        System.out.println(ans);
        sc.close();
    }
    private static int gcd(int m, int n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java import java.math.*; math.* java public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int variety = sc.nextInt();
        int[] k = new int[n];
        int[] preference = new int[variety];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        }
        for (int i = 0; i < variety; i++) {
            if (preference[i] == n) {
                ans++;
            } 
        }
        System.out.println(ans);
        sc.close();
    }
    private static int gcd(int m, int n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int variety = sc.nextInt();
        int[] k = new int[n];
        int[] preference = new int[variety];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        }
        for (int i = 0; i < variety; i++) {
            if (preference[i] == n) {
                ans++;
            } 
        }
        System.out.println(ans);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int variety = sc.nextInt();
        int[] k = new int[n];
        int[] preference = new int[variety];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        }
        for (int i = 0; i < variety; i++) {
            if (preference[i] == n) {
                ans++;
            } 
        }
        System.out.println(ans);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int variety = sc.nextInt(); variety sc.nextInt() sc.nextInt sc int[] k = new int[n]; k new int[n] n int[] preference = new int[variety]; preference new int[variety] variety int ans = 0; ans 0 for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        } {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        } k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            } int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            } {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            } int tmp = sc.nextInt(); tmp sc.nextInt() sc.nextInt sc preference[tmp-1]++ preference[tmp-1] preference tmp-1 tmp 1 for (int i = 0; i < variety; i++) {
            if (preference[i] == n) {
                ans++;
            } 
        } int i = 0; int i = 0; i 0 i < variety i variety i++ i++ i {
            if (preference[i] == n) {
                ans++;
            } 
        } {
            if (preference[i] == n) {
                ans++;
            } 
        } if (preference[i] == n) {
                ans++;
            } preference[i] == n preference[i] preference i n {
                ans++;
            } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String args[] args private static int gcd(int m, int n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    } gcd {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    } if(m < n) {
            return gcd(n, m);
        } m < n m n {
            return gcd(n, m);
        } return gcd(n, m); gcd(n, m) gcd n m if(n == 0){
            return m;
        } n == 0 n 0 {
            return m;
        } return m; m return gcd(n, m % n); gcd(n, m % n) gcd n m % n m n int m m int n n public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int variety = sc.nextInt();
        int[] k = new int[n];
        int[] preference = new int[variety];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        }
        for (int i = 0; i < variety; i++) {
            if (preference[i] == n) {
                ans++;
            } 
        }
        System.out.println(ans);
        sc.close();
    }
    private static int gcd(int m, int n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }
} public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int variety = sc.nextInt();
        int[] k = new int[n];
        int[] preference = new int[variety];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        }
        for (int i = 0; i < variety; i++) {
            if (preference[i] == n) {
                ans++;
            } 
        }
        System.out.println(ans);
        sc.close();
    }
    private static int gcd(int m, int n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }
} Main
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int variety = sc.nextInt();
        int[] k = new int[n];
        int[] preference = new int[variety];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int tmp = sc.nextInt();
                preference[tmp-1]++;
            }
        }
        for (int i = 0; i < variety; i++) {
            if (preference[i] == n) {
                ans++;
            } 
        }
        System.out.println(ans);
        sc.close();
    }
    private static int gcd(int m, int n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }
}