import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), total=0;
    int A[] = new int[M];
    for(int i=0; i<M; i++) {
      A[i] = 0;
    }
    
    for(int j=0; j<N; j++) {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    }
    
    for(int l=0; l<M; l++) {
      if(A[l] == N) {
        total++;
      }
    }
    System.out.println(total);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), total=0;
    int A[] = new int[M];
    for(int i=0; i<M; i++) {
      A[i] = 0;
    }
    
    for(int j=0; j<N; j++) {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    }
    
    for(int l=0; l<M; l++) {
      if(A[l] == N) {
        total++;
      }
    }
    System.out.println(total);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), total=0;
    int A[] = new int[M];
    for(int i=0; i<M; i++) {
      A[i] = 0;
    }
    
    for(int j=0; j<N; j++) {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    }
    
    for(int l=0; l<M; l++) {
      if(A[l] == N) {
        total++;
      }
    }
    System.out.println(total);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), total=0;
    int A[] = new int[M];
    for(int i=0; i<M; i++) {
      A[i] = 0;
    }
    
    for(int j=0; j<N; j++) {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    }
    
    for(int l=0; l<M; l++) {
      if(A[l] == N) {
        total++;
      }
    }
    System.out.println(total);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt() N sc.nextInt() sc.nextInt sc M = sc.nextInt() M sc.nextInt() sc.nextInt sc total=0; total 0 int A[] = new int[M]; A new int[M] M for(int i=0; i<M; i++) {
      A[i] = 0;
    } int i=0; int i=0; i 0 i<M i M i++ i++ i {
      A[i] = 0;
    } {
      A[i] = 0;
    } A[i] = 0 A[i] A i 0 for(int j=0; j<N; j++) {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    } int j=0; int j=0; j 0 j<N j N j++ j++ j {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    } {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    } int L = sc.nextInt(); L sc.nextInt() sc.nextInt sc for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      } int k=0; int k=0; k 0 k<L k L k++ k++ k {
        int f = sc.nextInt();
        A[f-1] ++;
      } {
        int f = sc.nextInt();
        A[f-1] ++;
      } int f = sc.nextInt(); f sc.nextInt() sc.nextInt sc A[f-1] ++ A[f-1] A f-1 f 1 for(int l=0; l<M; l++) {
      if(A[l] == N) {
        total++;
      }
    } int l=0; int l=0; l 0 l<M l M l++ l++ l {
      if(A[l] == N) {
        total++;
      }
    } {
      if(A[l] == N) {
        total++;
      }
    } if(A[l] == N) {
        total++;
      } A[l] == N A[l] A l N {
        total++;
      } total++ total System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), total=0;
    int A[] = new int[M];
    for(int i=0; i<M; i++) {
      A[i] = 0;
    }
    
    for(int j=0; j<N; j++) {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    }
    
    for(int l=0; l<M; l++) {
      if(A[l] == N) {
        total++;
      }
    }
    System.out.println(total);
  }
} public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), total=0;
    int A[] = new int[M];
    for(int i=0; i<M; i++) {
      A[i] = 0;
    }
    
    for(int j=0; j<N; j++) {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    }
    
    for(int l=0; l<M; l++) {
      if(A[l] == N) {
        total++;
      }
    }
    System.out.println(total);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), total=0;
    int A[] = new int[M];
    for(int i=0; i<M; i++) {
      A[i] = 0;
    }
    
    for(int j=0; j<N; j++) {
      int L = sc.nextInt();
      for(int k=0; k<L; k++) {
        int f = sc.nextInt();
        A[f-1] ++;
      }
    }
    
    for(int l=0; l<M; l++) {
      if(A[l] == N) {
        total++;
      }
    }
    System.out.println(total);
  }
}