import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] freq = new int[M];
    for (int i = 0; i < N; i++) {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    }
    int tot = 0;
    for (int f : freq) if (f == N) tot++;
    System.out.println(tot);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] freq = new int[M];
    for (int i = 0; i < N; i++) {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    }
    int tot = 0;
    for (int f : freq) if (f == N) tot++;
    System.out.println(tot);
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] freq = new int[M];
    for (int i = 0; i < N; i++) {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    }
    int tot = 0;
    for (int f : freq) if (f == N) tot++;
    System.out.println(tot);
  } main {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] freq = new int[M];
    for (int i = 0; i < N; i++) {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    }
    int tot = 0;
    for (int f : freq) if (f == N) tot++;
    System.out.println(tot);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner int[] freq = new int[M]; freq new int[M] M for (int i = 0; i < N; i++) {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    } {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    } int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      } int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      } {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      } int a = scanner.nextInt() - 1; a scanner.nextInt() - 1 scanner.nextInt() scanner.nextInt scanner 1 freq[a]++ freq[a] freq a int tot = 0; tot 0 for (int f : freq) if (f == N) tot++; int f freq if (f == N) tot++; if (f == N) tot++; f == N f N tot++ tot System.out.println(tot) System.out.println System.out System System.out tot String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] freq = new int[M];
    for (int i = 0; i < N; i++) {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    }
    int tot = 0;
    for (int f : freq) if (f == N) tot++;
    System.out.println(tot);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] freq = new int[M];
    for (int i = 0; i < N; i++) {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    }
    int tot = 0;
    for (int f : freq) if (f == N) tot++;
    System.out.println(tot);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] freq = new int[M];
    for (int i = 0; i < N; i++) {
      int K = scanner.nextInt();
      for (int j = 0; j < K; j++) {
        int a = scanner.nextInt() - 1;
        freq[a]++;
      }
    }
    int tot = 0;
    for (int f : freq) if (f == N) tot++;
    System.out.println(tot);
  }
}
