import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    int m=scan.nextInt();
    int like[]=new int[m];
    int k;
    
    //reset
    for(int j=0;j<m;j++){
      like[j]=0;
    }
    for(int i=0;i<n;i++){
      k=scan.nextInt();
      for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      }
    }
    
    int count=0;
    for(int j=0;j<m;j++){
      if(like[j]==n) count+=1;
    }
    System.out.println(count);
  }
} import java.util.Scanner; Scanner java.util class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    int m=scan.nextInt();
    int like[]=new int[m];
    int k;
    
    //reset
    for(int j=0;j<m;j++){
      like[j]=0;
    }
    for(int i=0;i<n;i++){
      k=scan.nextInt();
      for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      }
    }
    
    int count=0;
    for(int j=0;j<m;j++){
      if(like[j]==n) count+=1;
    }
    System.out.println(count);
  }
} Main public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    int m=scan.nextInt();
    int like[]=new int[m];
    int k;
    
    //reset
    for(int j=0;j<m;j++){
      like[j]=0;
    }
    for(int i=0;i<n;i++){
      k=scan.nextInt();
      for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      }
    }
    
    int count=0;
    for(int j=0;j<m;j++){
      if(like[j]==n) count+=1;
    }
    System.out.println(count);
  } main {
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    int m=scan.nextInt();
    int like[]=new int[m];
    int k;
    
    //reset
    for(int j=0;j<m;j++){
      like[j]=0;
    }
    for(int i=0;i<n;i++){
      k=scan.nextInt();
      for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      }
    }
    
    int count=0;
    for(int j=0;j<m;j++){
      if(like[j]==n) count+=1;
    }
    System.out.println(count);
  } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int n=scan.nextInt(); n scan.nextInt() scan.nextInt scan int m=scan.nextInt(); m scan.nextInt() scan.nextInt scan int like[]=new int[m]; like new int[m] m int k; k for(int j=0;j<m;j++){
      like[j]=0;
    } int j=0; int j=0; j 0 j<m j m j++ j++ j {
      like[j]=0;
    } {
      like[j]=0;
    } like[j]=0 like[j] like j 0 for(int i=0;i<n;i++){
      k=scan.nextInt();
      for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      }
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      k=scan.nextInt();
      for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      }
    } {
      k=scan.nextInt();
      for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      }
    } k=scan.nextInt() k scan.nextInt() scan.nextInt scan for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      } int j=0; int j=0; j 0 j<k j k j++ j++ j {
        like[scan.nextInt()-1]+=1;
      } {
        like[scan.nextInt()-1]+=1;
      } like[scan.nextInt()-1]+=1 like[scan.nextInt()-1] like scan.nextInt()-1 scan.nextInt() scan.nextInt scan 1 1 int count=0; count 0 for(int j=0;j<m;j++){
      if(like[j]==n) count+=1;
    } int j=0; int j=0; j 0 j<m j m j++ j++ j {
      if(like[j]==n) count+=1;
    } {
      if(like[j]==n) count+=1;
    } if(like[j]==n) count+=1; like[j]==n like[j] like j n count+=1 count 1 System.out.println(count) System.out.println System.out System System.out count String args[] args
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    int m=scan.nextInt();
    int like[]=new int[m];
    int k;
    
    //reset
    for(int j=0;j<m;j++){
      like[j]=0;
    }
    for(int i=0;i<n;i++){
      k=scan.nextInt();
      for(int j=0;j<k;j++){
        like[scan.nextInt()-1]+=1;
      }
    }
    
    int count=0;
    for(int j=0;j<m;j++){
      if(like[j]==n) count+=1;
    }
    System.out.println(count);
  }
}
