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[] ans = new int[m+1];
    for(int i=1; i<n+1; i++) {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    }
    int cnt = 0;
    for(int i : ans) {
      if(n == i) cnt++;
    }
    System.out.println(cnt);
  }
} 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[] ans = new int[m+1];
    for(int i=1; i<n+1; i++) {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    }
    int cnt = 0;
    for(int i : ans) {
      if(n == i) cnt++;
    }
    System.out.println(cnt);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] ans = new int[m+1];
    for(int i=1; i<n+1; i++) {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    }
    int cnt = 0;
    for(int i : ans) {
      if(n == i) cnt++;
    }
    System.out.println(cnt);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] ans = new int[m+1];
    for(int i=1; i<n+1; i++) {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    }
    int cnt = 0;
    for(int i : ans) {
      if(n == i) cnt++;
    }
    System.out.println(cnt);
  } 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[] ans = new int[m+1]; ans new int[m+1] m+1 m 1 for(int i=1; i<n+1; i++) {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    } int i=1; int i=1; i 1 i<n+1 i n+1 n 1 i++ i++ i {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    } {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      } int j=0; int j=0; j 0 j<k j k j++ j++ j {
        ans[sc.nextInt()] += 1;
      } {
        ans[sc.nextInt()] += 1;
      } ans[sc.nextInt()] += 1 ans[sc.nextInt()] ans sc.nextInt() sc.nextInt sc 1 int cnt = 0; cnt 0 for(int i : ans) {
      if(n == i) cnt++;
    } int i ans {
      if(n == i) cnt++;
    } {
      if(n == i) cnt++;
    } if(n == i) cnt++; n == i n i cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt 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[] ans = new int[m+1];
    for(int i=1; i<n+1; i++) {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    }
    int cnt = 0;
    for(int i : ans) {
      if(n == i) cnt++;
    }
    System.out.println(cnt);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] ans = new int[m+1];
    for(int i=1; i<n+1; i++) {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    }
    int cnt = 0;
    for(int i : ans) {
      if(n == i) cnt++;
    }
    System.out.println(cnt);
  }
} 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[] ans = new int[m+1];
    for(int i=1; i<n+1; i++) {
      int k = sc.nextInt();
      for(int j=0; j<k; j++) {
        ans[sc.nextInt()] += 1;
      }
    }
    int cnt = 0;
    for(int i : ans) {
      if(n == i) cnt++;
    }
    System.out.println(cnt);
  }
}
