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