import java.util.*;

public class Main { 
	public static void main(String argsp[]) 
    {	
      	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int N = Integer.valueOf(inputs[0]);
      	int M = Integer.valueOf(inputs[1]);
      	int[] likedFood  = new int[M+1];
      	
      	for( int i = 0 ; i<N ; i++ )
        {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        }
      int ans = 0; 
      for( int i = 1 ; i<=M ; i++) {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      }
      System.out.println(ans);
    }
} import java.util.*; util.* java public class Main { 
	public static void main(String argsp[]) 
    {	
      	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int N = Integer.valueOf(inputs[0]);
      	int M = Integer.valueOf(inputs[1]);
      	int[] likedFood  = new int[M+1];
      	
      	for( int i = 0 ; i<N ; i++ )
        {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        }
      int ans = 0; 
      for( int i = 1 ; i<=M ; i++) {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      }
      System.out.println(ans);
    }
} Main public static void main(String argsp[]) 
    {	
      	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int N = Integer.valueOf(inputs[0]);
      	int M = Integer.valueOf(inputs[1]);
      	int[] likedFood  = new int[M+1];
      	
      	for( int i = 0 ; i<N ; i++ )
        {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        }
      int ans = 0; 
      for( int i = 1 ; i<=M ; i++) {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      }
      System.out.println(ans);
    } main {	
      	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int N = Integer.valueOf(inputs[0]);
      	int M = Integer.valueOf(inputs[1]);
      	int[] likedFood  = new int[M+1];
      	
      	for( int i = 0 ; i<N ; i++ )
        {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        }
      int ans = 0; 
      for( int i = 1 ; i<=M ; i++) {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      }
      System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc String[] inputs = input.split(" "); inputs input.split(" ") input.split input " " int N = Integer.valueOf(inputs[0]); N Integer.valueOf(inputs[0]) Integer.valueOf Integer inputs[0] inputs 0 int M = Integer.valueOf(inputs[1]); M Integer.valueOf(inputs[1]) Integer.valueOf Integer inputs[1] inputs 1 int[] likedFood  = new int[M+1]; likedFood new int[M+1] M+1 M 1 for( int i = 0 ; i<N ; i++ )
        {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        } int i = 0 ; int i = 0 ; i 0 i<N i N i++ i++ i {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        } {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        } input  = sc.nextLine() input sc.nextLine() sc.nextLine sc inputs = input.split(" ") inputs input.split(" ") input.split input " " int foodLiked = Integer.valueOf(inputs[0]); foodLiked Integer.valueOf(inputs[0]) Integer.valueOf Integer inputs[0] inputs 0 for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            } int j = 1 ; int j = 1 ; j 1 j<=foodLiked j foodLiked j++ j++ j {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            } {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            } int value = Integer.valueOf(inputs[j]); value Integer.valueOf(inputs[j]) Integer.valueOf Integer inputs[j] inputs j likedFood[value]+=1 likedFood[value] likedFood value 1 int ans = 0; ans 0 for( int i = 1 ; i<=M ; i++) {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      } int i = 1 ; int i = 1 ; i 1 i<=M i M i++ i++ i {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      } {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      } if(likedFood[i]==N)
        {
          ans++;
        } likedFood[i]==N likedFood[i] likedFood i N {
          ans++;
        } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String argsp[] argsp public class Main { 
	public static void main(String argsp[]) 
    {	
      	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int N = Integer.valueOf(inputs[0]);
      	int M = Integer.valueOf(inputs[1]);
      	int[] likedFood  = new int[M+1];
      	
      	for( int i = 0 ; i<N ; i++ )
        {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        }
      int ans = 0; 
      for( int i = 1 ; i<=M ; i++) {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      }
      System.out.println(ans);
    }
} public class Main { 
	public static void main(String argsp[]) 
    {	
      	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int N = Integer.valueOf(inputs[0]);
      	int M = Integer.valueOf(inputs[1]);
      	int[] likedFood  = new int[M+1];
      	
      	for( int i = 0 ; i<N ; i++ )
        {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        }
      int ans = 0; 
      for( int i = 1 ; i<=M ; i++) {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      }
      System.out.println(ans);
    }
} Main
import java.util.*;

public class Main { 
	public static void main(String argsp[]) 
    {	
      	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int N = Integer.valueOf(inputs[0]);
      	int M = Integer.valueOf(inputs[1]);
      	int[] likedFood  = new int[M+1];
      	
      	for( int i = 0 ; i<N ; i++ )
        {
          	input  = sc.nextLine();
          	inputs = input.split(" ");
          	int foodLiked = Integer.valueOf(inputs[0]);
          	for(int j = 1 ;j<=foodLiked ; j++)
            {
               int value = Integer.valueOf(inputs[j]);
               likedFood[value]+=1;
            }
        }
      int ans = 0; 
      for( int i = 1 ; i<=M ; i++) {
      	if(likedFood[i]==N)
        {
          ans++;
        }
      }
      System.out.println(ans);
    }
}