import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
        int ans = 0;
        int suko[] = new int[M];
        for (int i=0;i<M;i++){
          suko[i] = 0;
        }
      
        for (int i=0;i<N;i++){
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        }
        for (int i=0;i<M;i++){
          if (suko[i] == N){
            ans += 1;
          }
        }
     out.println(ans);
     out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
        int ans = 0;
        int suko[] = new int[M];
        for (int i=0;i<M;i++){
          suko[i] = 0;
        }
      
        for (int i=0;i<N;i++){
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        }
        for (int i=0;i<M;i++){
          if (suko[i] == N){
            ans += 1;
          }
        }
     out.println(ans);
     out.flush();
    }
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
        int ans = 0;
        int suko[] = new int[M];
        for (int i=0;i<M;i++){
          suko[i] = 0;
        }
      
        for (int i=0;i<N;i++){
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        }
        for (int i=0;i<M;i++){
          if (suko[i] == N){
            ans += 1;
          }
        }
     out.println(ans);
     out.flush();
    } main {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
        int ans = 0;
        int suko[] = new int[M];
        for (int i=0;i<M;i++){
          suko[i] = 0;
        }
      
        for (int i=0;i<N;i++){
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        }
        for (int i=0;i<M;i++){
          if (suko[i] == N){
            ans += 1;
          }
        }
     out.println(ans);
     out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int M = Integer.parseInt(sc.next()); M Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int ans = 0; ans 0 int suko[] = new int[M]; suko new int[M] M for (int i=0;i<M;i++){
          suko[i] = 0;
        } int i=0; int i=0; i 0 i<M i M i++ i++ i {
          suko[i] = 0;
        } {
          suko[i] = 0;
        } suko[i] = 0 suko[i] suko i 0 for (int i=0;i<N;i++){
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        } {
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        } int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          } int j=0; int j=0; j 0 j<K j K j++ j++ j {
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          } {
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          } int A = Integer.parseInt(sc.next()); A Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc suko[A-1] += 1 suko[A-1] suko A-1 A 1 1 for (int i=0;i<M;i++){
          if (suko[i] == N){
            ans += 1;
          }
        } int i=0; int i=0; i 0 i<M i M i++ i++ i {
          if (suko[i] == N){
            ans += 1;
          }
        } {
          if (suko[i] == N){
            ans += 1;
          }
        } if (suko[i] == N){
            ans += 1;
          } suko[i] == N suko[i] suko i N {
            ans += 1;
          } ans += 1 ans 1 out.println(ans) out.println out ans out.flush() out.flush out String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
        int ans = 0;
        int suko[] = new int[M];
        for (int i=0;i<M;i++){
          suko[i] = 0;
        }
      
        for (int i=0;i<N;i++){
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        }
        for (int i=0;i<M;i++){
          if (suko[i] == N){
            ans += 1;
          }
        }
     out.println(ans);
     out.flush();
    }
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
        int ans = 0;
        int suko[] = new int[M];
        for (int i=0;i<M;i++){
          suko[i] = 0;
        }
      
        for (int i=0;i<N;i++){
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        }
        for (int i=0;i<M;i++){
          if (suko[i] == N){
            ans += 1;
          }
        }
     out.println(ans);
     out.flush();
    }
} Main
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
        int ans = 0;
        int suko[] = new int[M];
        for (int i=0;i<M;i++){
          suko[i] = 0;
        }
      
        for (int i=0;i<N;i++){
          int K = Integer.parseInt(sc.next());
          for (int j=0;j<K;j++){
            int A = Integer.parseInt(sc.next());
            suko[A-1] += 1;
          }
        }
        for (int i=0;i<M;i++){
          if (suko[i] == N){
            ans += 1;
          }
        }
     out.println(ans);
     out.flush();
    }
}