import java.util.*;

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

  Scanner sc;
  int N;
  int M;
  int answer;
  int[] K;
  int[][] A;

  // 標準入力用のコンストラクタ
  public Main(Scanner sc) {
    this.sc = sc;
    N = sc.nextInt();   //調査人数
    M = sc.nextInt(); 	//食べ物の種類数
    K = new int[N]; 	//N人それぞれの好きな料理の個数
    A = new int[N][M];
    for (int i = 0; i < N; ++i){
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    }
  }

  // 判定処理
  int solve() {
      int count = 0;
      int[] like = new int[M];   //各料理ごとに好きだと答えた人数を格納する配列
      for (int i = 0; i < N; ++i){
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      }
      for (int i = 0; i < M; ++i){  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      }
      
      answer = count;
      return answer;
  }

  // 回答の表示
  void show(int answer) {
        System.out.println(answer);
  }
    
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Main m = new Main(sc);
    m.show(m.solve());
  }

  Scanner sc;
  int N;
  int M;
  int answer;
  int[] K;
  int[][] A;

  // 標準入力用のコンストラクタ
  public Main(Scanner sc) {
    this.sc = sc;
    N = sc.nextInt();   //調査人数
    M = sc.nextInt(); 	//食べ物の種類数
    K = new int[N]; 	//N人それぞれの好きな料理の個数
    A = new int[N][M];
    for (int i = 0; i < N; ++i){
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    }
  }

  // 判定処理
  int solve() {
      int count = 0;
      int[] like = new int[M];   //各料理ごとに好きだと答えた人数を格納する配列
      for (int i = 0; i < N; ++i){
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      }
      for (int i = 0; i < M; ++i){  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      }
      
      answer = count;
      return answer;
  }

  // 回答の表示
  void show(int answer) {
        System.out.println(answer);
  }
    
} Main Scanner sc; sc int N; N int M; M int answer; answer int[] K; K int[][] A; A public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Main m = new Main(sc);
    m.show(m.solve());
  } main {
    Scanner sc = new Scanner(System.in);
    Main m = new Main(sc);
    m.show(m.solve());
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Main m = new Main(sc); m new Main(sc) m.show(m.solve()) m.show m m.solve() m.solve m String[] args args // 標準入力用のコンストラクタ
  public Main(Scanner sc) {
    this.sc = sc;
    N = sc.nextInt();   //調査人数
    M = sc.nextInt(); 	//食べ物の種類数
    K = new int[N]; 	//N人それぞれの好きな料理の個数
    A = new int[N][M];
    for (int i = 0; i < N; ++i){
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    }
  } Main {
    this.sc = sc;
    N = sc.nextInt();   //調査人数
    M = sc.nextInt(); 	//食べ物の種類数
    K = new int[N]; 	//N人それぞれの好きな料理の個数
    A = new int[N][M];
    for (int i = 0; i < N; ++i){
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    }
  } this.sc = sc this.sc this this.sc sc N = sc.nextInt() N sc.nextInt() sc.nextInt sc M = sc.nextInt() M sc.nextInt() sc.nextInt sc K = new int[N] K new int[N] N A = new int[N][M] A new int[N][M] N M for (int i = 0; i < N; ++i){
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    } int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    } {
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    } K[i] = sc.nextInt() K[i] K i sc.nextInt() sc.nextInt sc for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        } int j = 0; int j = 0; j 0 j < K[i] j K[i] K i ++j ++j j {
            A[i][j] = sc.nextInt();
        } {
            A[i][j] = sc.nextInt();
        } A[i][j] = sc.nextInt() A[i][j] A[i] A i j sc.nextInt() sc.nextInt sc Scanner sc sc // 判定処理
  int solve() {
      int count = 0;
      int[] like = new int[M];   //各料理ごとに好きだと答えた人数を格納する配列
      for (int i = 0; i < N; ++i){
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      }
      for (int i = 0; i < M; ++i){  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      }
      
      answer = count;
      return answer;
  } solve {
      int count = 0;
      int[] like = new int[M];   //各料理ごとに好きだと答えた人数を格納する配列
      for (int i = 0; i < N; ++i){
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      }
      for (int i = 0; i < M; ++i){  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      }
      
      answer = count;
      return answer;
  } int count = 0; count 0 int[] like = new int[M]; like new int[M] M for (int i = 0; i < N; ++i){
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      } int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      } {
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      } for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        } int j = 0; int j = 0; j 0 j < K[i] j K[i] K i ++j ++j j {
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        } {
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        } like[A[i][j] -1]++ like[A[i][j] -1] like A[i][j] -1 A[i][j] A[i] A i j 1 for (int i = 0; i < M; ++i){  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      } int i = 0; int i = 0; i 0 i < M i M ++i ++i i {  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      } {  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      } if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        } like[i] == N like[i] like i N {  //その料理を全員が好きであればカウント
            ++count;
        } ++count count answer = count answer count return answer; answer // 回答の表示
  void show(int answer) {
        System.out.println(answer);
  } show {
        System.out.println(answer);
  } System.out.println(answer) System.out.println System.out System System.out answer int answer answer public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Main m = new Main(sc);
    m.show(m.solve());
  }

  Scanner sc;
  int N;
  int M;
  int answer;
  int[] K;
  int[][] A;

  // 標準入力用のコンストラクタ
  public Main(Scanner sc) {
    this.sc = sc;
    N = sc.nextInt();   //調査人数
    M = sc.nextInt(); 	//食べ物の種類数
    K = new int[N]; 	//N人それぞれの好きな料理の個数
    A = new int[N][M];
    for (int i = 0; i < N; ++i){
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    }
  }

  // 判定処理
  int solve() {
      int count = 0;
      int[] like = new int[M];   //各料理ごとに好きだと答えた人数を格納する配列
      for (int i = 0; i < N; ++i){
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      }
      for (int i = 0; i < M; ++i){  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      }
      
      answer = count;
      return answer;
  }

  // 回答の表示
  void show(int answer) {
        System.out.println(answer);
  }
    
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Main m = new Main(sc);
    m.show(m.solve());
  }

  Scanner sc;
  int N;
  int M;
  int answer;
  int[] K;
  int[][] A;

  // 標準入力用のコンストラクタ
  public Main(Scanner sc) {
    this.sc = sc;
    N = sc.nextInt();   //調査人数
    M = sc.nextInt(); 	//食べ物の種類数
    K = new int[N]; 	//N人それぞれの好きな料理の個数
    A = new int[N][M];
    for (int i = 0; i < N; ++i){
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    }
  }

  // 判定処理
  int solve() {
      int count = 0;
      int[] like = new int[M];   //各料理ごとに好きだと答えた人数を格納する配列
      for (int i = 0; i < N; ++i){
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      }
      for (int i = 0; i < M; ++i){  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      }
      
      answer = count;
      return answer;
  }

  // 回答の表示
  void show(int answer) {
        System.out.println(answer);
  }
    
} Main
import java.util.*;

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

  Scanner sc;
  int N;
  int M;
  int answer;
  int[] K;
  int[][] A;

  // 標準入力用のコンストラクタ
  public Main(Scanner sc) {
    this.sc = sc;
    N = sc.nextInt();   //調査人数
    M = sc.nextInt(); 	//食べ物の種類数
    K = new int[N]; 	//N人それぞれの好きな料理の個数
    A = new int[N][M];
    for (int i = 0; i < N; ++i){
        K[i] = sc.nextInt();
        for (int j = 0; j < K[i]; ++j){
            A[i][j] = sc.nextInt();
        }
    }
  }

  // 判定処理
  int solve() {
      int count = 0;
      int[] like = new int[M];   //各料理ごとに好きだと答えた人数を格納する配列
      for (int i = 0; i < N; ++i){
        for (int j = 0; j < K[i]; ++j){
            like[A[i][j] -1]++; //K[i]番目の料理が好き
        }
      }
      for (int i = 0; i < M; ++i){  //各料理の「好きだ」と解答した人数を調べる
        if (like[i] == N){  //その料理を全員が好きであればカウント
            ++count;
        }
      }
      
      answer = count;
      return answer;
  }

  // 回答の表示
  void show(int answer) {
        System.out.println(answer);
  }
    
}