import java.util.*;

public class Main 
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        logic(sc);
    }
    
    public static void logic(Scanner sc)
    {
        int ans = 0;
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] mArr = new int[m+1];
        for(int i=1;i<=n;i++)
        {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        }
        for(int i=0;i<mArr.length;i++)
            if(mArr[i]==n)
                ans++;
        
        sc.close();
        System.out.print(ans);
    }
} import java.util.*; util.* java public class Main 
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        logic(sc);
    }
    
    public static void logic(Scanner sc)
    {
        int ans = 0;
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] mArr = new int[m+1];
        for(int i=1;i<=n;i++)
        {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        }
        for(int i=0;i<mArr.length;i++)
            if(mArr[i]==n)
                ans++;
        
        sc.close();
        System.out.print(ans);
    }
} Main public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        logic(sc);
    } main {
        Scanner sc = new Scanner(System.in);
        logic(sc);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) logic(sc) logic sc String[] args args public static void logic(Scanner sc)
    {
        int ans = 0;
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] mArr = new int[m+1];
        for(int i=1;i<=n;i++)
        {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        }
        for(int i=0;i<mArr.length;i++)
            if(mArr[i]==n)
                ans++;
        
        sc.close();
        System.out.print(ans);
    } logic {
        int ans = 0;
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] mArr = new int[m+1];
        for(int i=1;i<=n;i++)
        {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        }
        for(int i=0;i<mArr.length;i++)
            if(mArr[i]==n)
                ans++;
        
        sc.close();
        System.out.print(ans);
    } int ans = 0; ans 0 int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] mArr = new int[m+1]; mArr new int[m+1] m+1 m 1 for(int i=1;i<=n;i++)
        {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        } {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        } int ki = sc.nextInt(); ki sc.nextInt() sc.nextInt sc for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            } int j=1; int j=1; j 1 j<=ki j ki j++ j++ j {
                mArr[sc.nextInt()]++;
            } {
                mArr[sc.nextInt()]++;
            } mArr[sc.nextInt()]++ mArr[sc.nextInt()] mArr sc.nextInt() sc.nextInt sc for(int i=0;i<mArr.length;i++)
            if(mArr[i]==n)
                ans++; int i=0; int i=0; i 0 i<mArr.length i mArr.length mArr mArr.length i++ i++ i if(mArr[i]==n)
                ans++; if(mArr[i]==n)
                ans++; mArr[i]==n mArr[i] mArr i n ans++ ans sc.close() sc.close sc System.out.print(ans) System.out.print System.out System System.out ans Scanner sc sc public class Main 
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        logic(sc);
    }
    
    public static void logic(Scanner sc)
    {
        int ans = 0;
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] mArr = new int[m+1];
        for(int i=1;i<=n;i++)
        {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        }
        for(int i=0;i<mArr.length;i++)
            if(mArr[i]==n)
                ans++;
        
        sc.close();
        System.out.print(ans);
    }
} public class Main 
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        logic(sc);
    }
    
    public static void logic(Scanner sc)
    {
        int ans = 0;
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] mArr = new int[m+1];
        for(int i=1;i<=n;i++)
        {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        }
        for(int i=0;i<mArr.length;i++)
            if(mArr[i]==n)
                ans++;
        
        sc.close();
        System.out.print(ans);
    }
} Main
import java.util.*;

public class Main 
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        logic(sc);
    }
    
    public static void logic(Scanner sc)
    {
        int ans = 0;
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] mArr = new int[m+1];
        for(int i=1;i<=n;i++)
        {
            int ki = sc.nextInt();
            for(int j=1;j<=ki;j++)
            {
                mArr[sc.nextInt()]++;
            }
        }
        for(int i=0;i<mArr.length;i++)
            if(mArr[i]==n)
                ans++;
        
        sc.close();
        System.out.print(ans);
    }
}
