
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int m = cin.nextInt();
    int[] kinds = new int[m];

    for (int i=0;i<n;i++) {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    }
    int count = 0;
    for (int i: kinds) {
      if (i==n)
        count+=1;
    }
    System.out.println(count);
  }

} import java.io.FileNotFoundException; FileNotFoundException java.io import java.io.FileReader; FileReader java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int m = cin.nextInt();
    int[] kinds = new int[m];

    for (int i=0;i<n;i++) {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    }
    int count = 0;
    for (int i: kinds) {
      if (i==n)
        count+=1;
    }
    System.out.println(count);
  }

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

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int m = cin.nextInt();
    int[] kinds = new int[m];

    for (int i=0;i<n;i++) {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    }
    int count = 0;
    for (int i: kinds) {
      if (i==n)
        count+=1;
    }
    System.out.println(count);
  } main {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int m = cin.nextInt();
    int[] kinds = new int[m];

    for (int i=0;i<n;i++) {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    }
    int count = 0;
    for (int i: kinds) {
      if (i==n)
        count+=1;
    }
    System.out.println(count);
  } Scanner cin = new Scanner(System.in); cin new Scanner(System.in) int n = cin.nextInt(); n cin.nextInt() cin.nextInt cin int m = cin.nextInt(); m cin.nextInt() cin.nextInt cin int[] kinds = new int[m]; kinds new int[m] m for (int i=0;i<n;i++) {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    } int i=0; int i=0; i 0 i<n i n i++ i++ i {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    } {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    } int k = cin.nextInt(); k cin.nextInt() cin.nextInt cin for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      } int j=0; int j=0; j 0 j<k j k j++ j++ j {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      } {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      } int in = cin.nextInt(); in cin.nextInt() cin.nextInt cin kinds[in-1]+=1 kinds[in-1] kinds in-1 in 1 1 int count = 0; count 0 for (int i: kinds) {
      if (i==n)
        count+=1;
    } int i kinds {
      if (i==n)
        count+=1;
    } {
      if (i==n)
        count+=1;
    } if (i==n)
        count+=1; i==n i n count+=1 count 1 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) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int m = cin.nextInt();
    int[] kinds = new int[m];

    for (int i=0;i<n;i++) {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    }
    int count = 0;
    for (int i: kinds) {
      if (i==n)
        count+=1;
    }
    System.out.println(count);
  }

} public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int m = cin.nextInt();
    int[] kinds = new int[m];

    for (int i=0;i<n;i++) {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    }
    int count = 0;
    for (int i: kinds) {
      if (i==n)
        count+=1;
    }
    System.out.println(count);
  }

} Main

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int m = cin.nextInt();
    int[] kinds = new int[m];

    for (int i=0;i<n;i++) {

      int k = cin.nextInt();
      for (int j=0;j<k;j++) {
        int in = cin.nextInt();
        kinds[in-1]+=1;
      }

    }
    int count = 0;
    for (int i: kinds) {
      if (i==n)
        count+=1;
    }
    System.out.println(count);
  }

}