import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   
   int[] Ai = new int[M];
   int K =0;
   int tmp = 0;
   for(int i=0;i<N;i++)
   {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   }
   
   int count = 0;
   for(int i = 0;i<M;i++)
   {
     if(Ai[i]==N) count++;
   }
   System.out.println(count);
 }
} import java.util.*; util.* java public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   
   int[] Ai = new int[M];
   int K =0;
   int tmp = 0;
   for(int i=0;i<N;i++)
   {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   }
   
   int count = 0;
   for(int i = 0;i<M;i++)
   {
     if(Ai[i]==N) count++;
   }
   System.out.println(count);
 }
} Main public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   
   int[] Ai = new int[M];
   int K =0;
   int tmp = 0;
   for(int i=0;i<N;i++)
   {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   }
   
   int count = 0;
   for(int i = 0;i<M;i++)
   {
     if(Ai[i]==N) count++;
   }
   System.out.println(count);
 } main {
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   
   int[] Ai = new int[M];
   int K =0;
   int tmp = 0;
   for(int i=0;i<N;i++)
   {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   }
   
   int count = 0;
   for(int i = 0;i<M;i++)
   {
     if(Ai[i]==N) count++;
   }
   System.out.println(count);
 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int[] Ai = new int[M]; Ai new int[M] M int K =0; K 0 int tmp = 0; tmp 0 for(int i=0;i<N;i++)
   {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   } int i=0; int i=0; i 0 i<N i N i++ i++ i {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   } {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   } K = sc.nextInt() K sc.nextInt() sc.nextInt sc for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     } int l = 0; int l = 0; l 0 l<K l K l++ l++ l {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     } {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     } tmp = sc.nextInt() tmp sc.nextInt() sc.nextInt sc Ai[tmp-1]++ Ai[tmp-1] Ai tmp-1 tmp 1 int count = 0; count 0 for(int i = 0;i<M;i++)
   {
     if(Ai[i]==N) count++;
   } int i = 0; int i = 0; i 0 i<M i M i++ i++ i {
     if(Ai[i]==N) count++;
   } {
     if(Ai[i]==N) count++;
   } if(Ai[i]==N) count++; Ai[i]==N Ai[i] Ai i N count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   
   int[] Ai = new int[M];
   int K =0;
   int tmp = 0;
   for(int i=0;i<N;i++)
   {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   }
   
   int count = 0;
   for(int i = 0;i<M;i++)
   {
     if(Ai[i]==N) count++;
   }
   System.out.println(count);
 }
} public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   
   int[] Ai = new int[M];
   int K =0;
   int tmp = 0;
   for(int i=0;i<N;i++)
   {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   }
   
   int count = 0;
   for(int i = 0;i<M;i++)
   {
     if(Ai[i]==N) count++;
   }
   System.out.println(count);
 }
} Main
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   
   int[] Ai = new int[M];
   int K =0;
   int tmp = 0;
   for(int i=0;i<N;i++)
   {
     K = sc.nextInt();
     for(int l = 0;l<K;l++)
     {
       tmp = sc.nextInt();
       Ai[tmp-1]++;
     }
   }
   
   int count = 0;
   for(int i = 0;i<M;i++)
   {
     if(Ai[i]==N) count++;
   }
   System.out.println(count);
 }
}