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[] K = new int[N];
    int[][] A = new int[N][];

    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    sc.close();

    int[] m = new int[M+1];

    for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    }

    int count = 0;

    for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    }

    System.out.println(count);

  }

} 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[] K = new int[N];
    int[][] A = new int[N][];

    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    sc.close();

    int[] m = new int[M+1];

    for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    }

    int count = 0;

    for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    }

    System.out.println(count);

  }

} Main public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] K = new int[N];
    int[][] A = new int[N][];

    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    sc.close();

    int[] m = new int[M+1];

    for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    }

    int count = 0;

    for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    }

    System.out.println(count);

  } main {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] K = new int[N];
    int[][] A = new int[N][];

    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    sc.close();

    int[] m = new int[M+1];

    for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    }

    int count = 0;

    for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    }

    System.out.println(count);

  } 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[] K = new int[N]; K new int[N] N int[][] A = new int[N][]; A new int[N][] N for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    } {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    } K[i] = sc.nextInt() K[i] K i sc.nextInt() sc.nextInt sc A[i] = new int[K[i]] A[i] A i new int[K[i]] K[i] K i for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      } int j = 0; int j = 0; j 0 j < K[i] j K[i] K i j++ j++ j {
        A[i][j] = sc.nextInt();
      } {
        A[i][j] = sc.nextInt();
      } A[i][j] = sc.nextInt() A[i][j] A[i] A i j sc.nextInt() sc.nextInt sc sc.close() sc.close sc int[] m = new int[M+1]; m new int[M+1] M+1 M 1 for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    } {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    } for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      } int j = 0; int j = 0; j 0 j < K[i] j K[i] K i j++ j++ j {

        m[A[i][j]]++;

      } {

        m[A[i][j]]++;

      } m[A[i][j]]++ m[A[i][j]] m A[i][j] A[i] A i j int count = 0; count 0 for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    } int i = 0; int i = 0; i 0 i < M+1 i M+1 M 1 i++ i++ i {
      if (m[i] == N) {
        count++;
      }
    } {
      if (m[i] == N) {
        count++;
      }
    } if (m[i] == N) {
        count++;
      } m[i] == N m[i] m i N {
        count++;
      } count++ count System.out.println(count) System.out.println System.out System System.out count 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[] K = new int[N];
    int[][] A = new int[N][];

    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    sc.close();

    int[] m = new int[M+1];

    for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    }

    int count = 0;

    for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    }

    System.out.println(count);

  }

} public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] K = new int[N];
    int[][] A = new int[N][];

    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    sc.close();

    int[] m = new int[M+1];

    for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    }

    int count = 0;

    for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    }

    System.out.println(count);

  }

} 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[] K = new int[N];
    int[][] A = new int[N][];

    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    sc.close();

    int[] m = new int[M+1];

    for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    }

    int count = 0;

    for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    }

    System.out.println(count);

  }

}