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[N][M+1];
    for(int i = 0; i < N; ++i){
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    }
    
    //みんなが好きなもの数える用
    int count[] = new int[M];
    for(int i = 0; i < M; ++i){
      count[i] = 0;
    }
    
    //数えよう
    for(int i = 0; i < N; ++i){
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    }
    
    int ans = 0;
    
    for(int i = 0; i < M; ++i){
      if(count[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[N][M+1];
    for(int i = 0; i < N; ++i){
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    }
    
    //みんなが好きなもの数える用
    int count[] = new int[M];
    for(int i = 0; i < M; ++i){
      count[i] = 0;
    }
    
    //数えよう
    for(int i = 0; i < N; ++i){
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    }
    
    int ans = 0;
    
    for(int i = 0; i < M; ++i){
      if(count[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[N][M+1];
    for(int i = 0; i < N; ++i){
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    }
    
    //みんなが好きなもの数える用
    int count[] = new int[M];
    for(int i = 0; i < M; ++i){
      count[i] = 0;
    }
    
    //数えよう
    for(int i = 0; i < N; ++i){
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    }
    
    int ans = 0;
    
    for(int i = 0; i < M; ++i){
      if(count[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[N][M+1];
    for(int i = 0; i < N; ++i){
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    }
    
    //みんなが好きなもの数える用
    int count[] = new int[M];
    for(int i = 0; i < M; ++i){
      count[i] = 0;
    }
    
    //数えよう
    for(int i = 0; i < N; ++i){
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    }
    
    int ans = 0;
    
    for(int i = 0; i < M; ++i){
      if(count[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[N][M+1]; like new int[N][M+1] N M+1 M 1 for(int i = 0; i < N; ++i){
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    } int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    } {
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    } like[i][0] = sc.nextInt() like[i][0] like[i] like i 0 sc.nextInt() sc.nextInt sc for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      } int j = 1; int j = 1; j 1 j <= like[i][0] j like[i][0] like[i] like i 0 ++j ++j j {
          like[i][j] = sc.nextInt();
      } {
          like[i][j] = sc.nextInt();
      } like[i][j] = sc.nextInt() like[i][j] like[i] like i j sc.nextInt() sc.nextInt sc int count[] = new int[M]; count new int[M] M for(int i = 0; i < M; ++i){
      count[i] = 0;
    } int i = 0; int i = 0; i 0 i < M i M ++i ++i i {
      count[i] = 0;
    } {
      count[i] = 0;
    } count[i] = 0 count[i] count i 0 for(int i = 0; i < N; ++i){
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    } int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    } {
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    } for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      } int j = 1; int j = 1; j 1 j < M+1 j M+1 M 1 ++j ++j j {
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      } {
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      } for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        } int k = 1; int k = 1; k 1 k <= M k M ++k ++k k {
          if(k == like[i][j]){
            count[k-1] ++;
          }
        } {
          if(k == like[i][j]){
            count[k-1] ++;
          }
        } if(k == like[i][j]){
            count[k-1] ++;
          } k == like[i][j] k like[i][j] like[i] like i j {
            count[k-1] ++;
          } count[k-1] ++ count[k-1] count k-1 k 1 int ans = 0; ans 0 for(int i = 0; i < M; ++i){
      if(count[i] == N){       
        ans++;        
      }
    } int i = 0; int i = 0; i 0 i < M i M ++i ++i i {
      if(count[i] == N){       
        ans++;        
      }
    } {
      if(count[i] == N){       
        ans++;        
      }
    } if(count[i] == N){       
        ans++;        
      } count[i] == N count[i] count 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[N][M+1];
    for(int i = 0; i < N; ++i){
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    }
    
    //みんなが好きなもの数える用
    int count[] = new int[M];
    for(int i = 0; i < M; ++i){
      count[i] = 0;
    }
    
    //数えよう
    for(int i = 0; i < N; ++i){
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    }
    
    int ans = 0;
    
    for(int i = 0; i < M; ++i){
      if(count[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[N][M+1];
    for(int i = 0; i < N; ++i){
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    }
    
    //みんなが好きなもの数える用
    int count[] = new int[M];
    for(int i = 0; i < M; ++i){
      count[i] = 0;
    }
    
    //数えよう
    for(int i = 0; i < N; ++i){
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    }
    
    int ans = 0;
    
    for(int i = 0; i < M; ++i){
      if(count[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[N][M+1];
    for(int i = 0; i < N; ++i){
      like[i][0] = sc.nextInt();
      for(int j = 1; j <= like[i][0]; ++j){
          like[i][j] = sc.nextInt();
      }
    }
    
    //みんなが好きなもの数える用
    int count[] = new int[M];
    for(int i = 0; i < M; ++i){
      count[i] = 0;
    }
    
    //数えよう
    for(int i = 0; i < N; ++i){
      for(int j = 1; j < M+1; ++j){
        for(int k = 1; k <= M; ++k){
          if(k == like[i][j]){
            count[k-1] ++;
          }
        }
      }
    }
    
    int ans = 0;
    
    for(int i = 0; i < M; ++i){
      if(count[i] == N){       
        ans++;        
      }
    }
    
    System.out.println(ans);
        
  } 
}