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[] suki = new int[m+1];
    for(int i = 0;i<n;i++){
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    }
    int all=0;
    for(int i = 1;i<=m;i++){
      if(suki[i]==n)all++;
    }
    System.out.println(all);
  }
} 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[] suki = new int[m+1];
    for(int i = 0;i<n;i++){
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    }
    int all=0;
    for(int i = 1;i<=m;i++){
      if(suki[i]==n)all++;
    }
    System.out.println(all);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] suki = new int[m+1];
    for(int i = 0;i<n;i++){
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    }
    int all=0;
    for(int i = 1;i<=m;i++){
      if(suki[i]==n)all++;
    }
    System.out.println(all);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] suki = new int[m+1];
    for(int i = 0;i<n;i++){
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    }
    int all=0;
    for(int i = 1;i<=m;i++){
      if(suki[i]==n)all++;
    }
    System.out.println(all);
  } 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[] suki = new int[m+1]; suki new int[m+1] m+1 m 1 for(int i = 0;i<n;i++){
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    } {
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      } int j = 0; int j = 0; j 0 j<k j k j++ j++ j {
        suki[sc.nextInt()]++;
      } {
        suki[sc.nextInt()]++;
      } suki[sc.nextInt()]++ suki[sc.nextInt()] suki sc.nextInt() sc.nextInt sc int all=0; all 0 for(int i = 1;i<=m;i++){
      if(suki[i]==n)all++;
    } int i = 1; int i = 1; i 1 i<=m i m i++ i++ i {
      if(suki[i]==n)all++;
    } {
      if(suki[i]==n)all++;
    } if(suki[i]==n)all++; suki[i]==n suki[i] suki i n all++ all System.out.println(all) System.out.println System.out System System.out all 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[] suki = new int[m+1];
    for(int i = 0;i<n;i++){
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    }
    int all=0;
    for(int i = 1;i<=m;i++){
      if(suki[i]==n)all++;
    }
    System.out.println(all);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] suki = new int[m+1];
    for(int i = 0;i<n;i++){
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    }
    int all=0;
    for(int i = 1;i<=m;i++){
      if(suki[i]==n)all++;
    }
    System.out.println(all);
  }
} 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[] suki = new int[m+1];
    for(int i = 0;i<n;i++){
      int k = sc.nextInt();
      for(int j = 0;j<k;j++){
        suki[sc.nextInt()]++;
      }
    }
    int all=0;
    for(int i = 1;i<=m;i++){
      if(suki[i]==n)all++;
    }
    System.out.println(all);
  }
}
