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 arr[] = new int[M];
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        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 arr[] = new int[M];
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        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 arr[] = new int[M];
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        cnt++;
      }
    }
    System.out.println(cnt);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int arr[] = new int[M];
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        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 arr[] = new int[M]; arr new int[M] M int cnt = 0; cnt 0 for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    } 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++) {
        arr[sc.nextInt()-1]++;
      }
    } {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      } int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
        arr[sc.nextInt()-1]++;
      } {
        arr[sc.nextInt()-1]++;
      } arr[sc.nextInt()-1]++ arr[sc.nextInt()-1] arr sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        cnt++;
      }
    } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
      if (arr[i] == N) {
        cnt++;
      }
    } {
      if (arr[i] == N) {
        cnt++;
      }
    } if (arr[i] == N) {
        cnt++;
      } arr[i] == N arr[i] arr i N {
        cnt++;
      } 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 arr[] = new int[M];
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        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 arr[] = new int[M];
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        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 arr[] = new int[M];
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}