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 p = 0;
    int q = 0;
    int aa = (1<<m) - 1; //2^m-1
    int bb = 0;
    //System.out.println(aa);

    for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    }

    System.out.println(Integer.bitCount(bb));












  }
} 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 p = 0;
    int q = 0;
    int aa = (1<<m) - 1; //2^m-1
    int bb = 0;
    //System.out.println(aa);

    for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    }

    System.out.println(Integer.bitCount(bb));












  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();//メニューの数
    int p = 0;
    int q = 0;
    int aa = (1<<m) - 1; //2^m-1
    int bb = 0;
    //System.out.println(aa);

    for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    }

    System.out.println(Integer.bitCount(bb));












  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();//メニューの数
    int p = 0;
    int q = 0;
    int aa = (1<<m) - 1; //2^m-1
    int bb = 0;
    //System.out.println(aa);

    for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    }

    System.out.println(Integer.bitCount(bb));












  } 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 p = 0; p 0 int q = 0; q 0 int aa = (1<<m) - 1; aa (1<<m) - 1 (1<<m) 1 m 1 int bb = 0; bb 0 for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    } {
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    } int lo = sc.nextInt(); lo sc.nextInt() sc.nextInt sc for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      } int k=0; int k=0; k 0 k<lo k lo k++ k++ k {
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      } {
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      } p = sc.nextInt() p sc.nextInt() sc.nextInt sc q =  q + (int)Math.pow(2,p-1) q q + (int)Math.pow(2,p-1) q (int)Math.pow(2,p-1) Math.pow Math 2 p-1 p 1 if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      } i==0 i 0 {
        bb = q & aa;
      } bb = q & aa bb q & aa q aa {
        bb = bb & q;
      } bb = bb & q bb bb & q bb q q =0 q 0 System.out.println(Integer.bitCount(bb)) System.out.println System.out System System.out Integer.bitCount(bb) Integer.bitCount Integer bb 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 p = 0;
    int q = 0;
    int aa = (1<<m) - 1; //2^m-1
    int bb = 0;
    //System.out.println(aa);

    for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    }

    System.out.println(Integer.bitCount(bb));












  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();//メニューの数
    int p = 0;
    int q = 0;
    int aa = (1<<m) - 1; //2^m-1
    int bb = 0;
    //System.out.println(aa);

    for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    }

    System.out.println(Integer.bitCount(bb));












  }
} 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 p = 0;
    int q = 0;
    int aa = (1<<m) - 1; //2^m-1
    int bb = 0;
    //System.out.println(aa);

    for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    }

    System.out.println(Integer.bitCount(bb));












  }
}