import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[] count = new int[M];
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    }
    
    int ans = 0;
    for(int i = 0; i < M; i++){
      if(count[i] == N){
        ans++;
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[] count = new int[M];
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    }
    
    int ans = 0;
    for(int i = 0; i < M; i++){
      if(count[i] == N){
        ans++;
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[] count = new int[M];
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    }
    
    int ans = 0;
    for(int i = 0; i < M; i++){
      if(count[i] == N){
        ans++;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[] count = new int[M];
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    }
    
    int ans = 0;
    for(int i = 0; i < M; i++){
      if(count[i] == N){
        ans++;
      }
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] S = sc.nextLine().split(" "); S sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int N = Integer.parseInt(S[0]); N Integer.parseInt(S[0]) Integer.parseInt Integer S[0] S 0 int M = Integer.parseInt(S[1]); M Integer.parseInt(S[1]) Integer.parseInt Integer S[1] S 1 int[] count = new int[M]; count new int[M] M for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    } {
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    } String[] T = sc.nextLine().split(" "); T sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int K = Integer.parseInt(T[0]); K Integer.parseInt(T[0]) Integer.parseInt Integer T[0] T 0 for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      } int j = 1; int j = 1; j 1 j <= K j K j++ j++ j {
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      } {
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      } int n = Integer.parseInt(T[j]); n Integer.parseInt(T[j]) Integer.parseInt Integer T[j] T j count[n-1]++ count[n-1] count n-1 n 1 int ans = 0; ans 0 for(int i = 0; i < M; i++){
      if(count[i] == N){
        ans++;
      }
    } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
      if(count[i] == N){
        ans++;
      }
    } {
      if(count[i] == N){
        ans++;
      }
    } if(count[i] == N){
        ans++;
      } count[i] == N count[i] count 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);
    
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[] count = new int[M];
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    }
    
    int ans = 0;
    for(int i = 0; i < M; i++){
      if(count[i] == N){
        ans++;
      }
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[] count = new int[M];
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    }
    
    int ans = 0;
    for(int i = 0; i < M; i++){
      if(count[i] == N){
        ans++;
      }
    }
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[] count = new int[M];
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int K = Integer.parseInt(T[0]);
      for(int j = 1; j <= K; j++){
        int n = Integer.parseInt(T[j]);
        count[n-1]++;
      }
    }
    
    int ans = 0;
    for(int i = 0; i < M; i++){
      if(count[i] == N){
        ans++;
      }
    }
    System.out.println(ans);
  }
}