import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x[] = new int[b];
        for (int i=0;i<a;i++){
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        }
        int ret = 0;
        for (int k=0;k<b;k++){
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        }
        System.out.println(ret);

    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x[] = new int[b];
        for (int i=0;i<a;i++){
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        }
        int ret = 0;
        for (int k=0;k<b;k++){
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        }
        System.out.println(ret);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x[] = new int[b];
        for (int i=0;i<a;i++){
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        }
        int ret = 0;
        for (int k=0;k<b;k++){
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        }
        System.out.println(ret);

    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x[] = new int[b];
        for (int i=0;i<a;i++){
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        }
        int ret = 0;
        for (int k=0;k<b;k++){
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        }
        System.out.println(ret);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int x[] = new int[b]; x new int[b] b for (int i=0;i<a;i++){
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        } int i=0; int i=0; i 0 i<a i a i++ i++ i {
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        } {
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        } int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            } int j=0; int j=0; j 0 j<c j c j++ j++ j {
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            } {
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            } int d = sc.nextInt(); d sc.nextInt() sc.nextInt sc x[d-1]=x[d-1]+1 x[d-1] x d-1 d 1 x[d-1]+1 x[d-1] x d-1 d 1 1 int ret = 0; ret 0 for (int k=0;k<b;k++){
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        } int k=0; int k=0; k 0 k<b k b k++ k++ k {
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        } {
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        } if (a==x[k]) ret=ret+1; a==x[k] a x[k] x k ret=ret+1 ret ret+1 ret 1 System.out.println(ret) System.out.println System.out System System.out ret String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x[] = new int[b];
        for (int i=0;i<a;i++){
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        }
        int ret = 0;
        for (int k=0;k<b;k++){
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        }
        System.out.println(ret);

    }
}