import java.util.Scanner;

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

public class Main{
  static int K[];
  static int Like[];
  static int check[];
  static int A;
  static int count=0;
  public static void main(String args[]){
    check = new int[33];
    for(int i=0;i<33;i++){
      check[i]=0;
    }
    Scanner sc = new Scanner(System.in);
    int N;
    int M;
    N = sc.nextInt();
    M = sc.nextInt();
    K = new int[N];
  for(int i=0;i<N;i++){
    K[i]=sc.nextInt();
    for(int j=0;j<K[i];j++){
      A = sc.nextInt();
      check[A] += 1;
    }
  }
  for(int i=0;i<33;i++){
    if(check[i]==N){
      count += 1;
    }
  }
  System.out.println(count);
  }
}
