import java.util.*;
import static java.lang.Math.*;
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[m+1];
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; i++){
            if(a[i] == n){
                ans++;
            }
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; 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[m+1];
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; i++){
            if(a[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 a[] = new int[m+1];
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; i++){
            if(a[i] == n){
                ans++;
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[m+1];
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; i++){
            if(a[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 a[] = new int[m+1]; a new int[m+1] m+1 m 1 for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        } {
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        } int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            } int j=0; int j=0; j 0 j<num j num j++ j++ j {
                int t = sc.nextInt();
                a[t]++;
            } {
                int t = sc.nextInt();
                a[t]++;
            } int t = sc.nextInt(); t sc.nextInt() sc.nextInt sc a[t]++ a[t] a t int ans = 0; ans 0 for(int i=0; i<=m; i++){
            if(a[i] == n){
                ans++;
            }
        } int i=0; int i=0; i 0 i<=m i m i++ i++ i {
            if(a[i] == n){
                ans++;
            }
        } {
            if(a[i] == n){
                ans++;
            }
        } if(a[i] == n){
                ans++;
            } a[i] == n a[i] a i n {
                ans++;
            } 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){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[m+1];
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; i++){
            if(a[i] == n){
                ans++;
            }
        }
        System.out.println(ans);
    }
} 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[m+1];
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; i++){
            if(a[i] == n){
                ans++;
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.*;
import static java.lang.Math.*;
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[m+1];
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; i++){
            if(a[i] == n){
                ans++;
            }
        }
        System.out.println(ans);
    }
}
