import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] likes = new int[M];
    for (int i=0; i<N; i++) {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    }

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

    System.out.println(count);

  }
} import java.util.*; util.* java public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] likes = new int[M];
    for (int i=0; i<N; i++) {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    }

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

    System.out.println(count);

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

    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] likes = new int[M];
    for (int i=0; i<N; i++) {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    }

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

    System.out.println(count);

  } main {

    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] likes = new int[M];
    for (int i=0; i<N; i++) {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    }

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

    System.out.println(count);

  } int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int[] likes = new int[M]; likes new int[M] M for (int i=0; i<N; i++) {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    } {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    } int len = sc.nextInt(); len sc.nextInt() sc.nextInt sc for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      } int j=0; int j=0; j 0 j<len j len j++ j++ j {
        likes[sc.nextInt()-1]++;
      } {
        likes[sc.nextInt()-1]++;
      } likes[sc.nextInt()-1]++ likes[sc.nextInt()-1] likes sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 int count = 0; count 0 for (int i=0; i<M; i++) {
      if (likes[i] == N) count++;
    } int i=0; int i=0; i 0 i<M i M i++ i++ i {
      if (likes[i] == N) count++;
    } {
      if (likes[i] == N) count++;
    } if (likes[i] == N) count++; likes[i] == N likes[i] likes i N count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] likes = new int[M];
    for (int i=0; i<N; i++) {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    }

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

    System.out.println(count);

  }
} public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] likes = new int[M];
    for (int i=0; i<N; i++) {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    }

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

    System.out.println(count);

  }
} Main
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] likes = new int[M];
    for (int i=0; i<N; i++) {
      int len = sc.nextInt();
      for (int j=0; j<len; j++) {
        likes[sc.nextInt()-1]++;
      }
    }

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

    System.out.println(count);

  }
}
