import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    
    ArrayList<Integer> answer = new ArrayList<Integer>();
    for(int i=0;i<=M;i++){
      answer.add(0);
    }
    
    for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    }
    int ans = 0;
    for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    }
    System.out.println(ans);
  }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    
    ArrayList<Integer> answer = new ArrayList<Integer>();
    for(int i=0;i<=M;i++){
      answer.add(0);
    }
    
    for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    }
    int ans = 0;
    for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    
    ArrayList<Integer> answer = new ArrayList<Integer>();
    for(int i=0;i<=M;i++){
      answer.add(0);
    }
    
    for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    }
    int ans = 0;
    for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    }
    System.out.println(ans);
  } main {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    
    ArrayList<Integer> answer = new ArrayList<Integer>();
    for(int i=0;i<=M;i++){
      answer.add(0);
    }
    
    for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    }
    int ans = 0;
    for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    }
    System.out.println(ans);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = Integer.parseInt(scanner.next()); N Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner int M = Integer.parseInt(scanner.next()); M Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner ArrayList<Integer> answer = new ArrayList<Integer>(); answer new ArrayList<Integer>() for(int i=0;i<=M;i++){
      answer.add(0);
    } int i=0; int i=0; i 0 i<=M i M i++ i++ i {
      answer.add(0);
    } {
      answer.add(0);
    } answer.add(0) answer.add answer 0 for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    } {
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    } int A = Integer.parseInt(scanner.next()); A Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      } int j=0; int j=0; j 0 j<A j A j++ j++ j {
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      } {
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      } int input = Integer.parseInt(scanner.next()); input Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner int pre = answer.get(input); pre answer.get(input) answer.get answer input answer.set(input, pre + 1) answer.set answer input pre + 1 pre 1 int ans = 0; ans 0 for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    } int i=1; int i=1; i 1 i<=M i M i++ i++ i {
      if(answer.get(i) == N)
        ans++;
    } {
      if(answer.get(i) == N)
        ans++;
    } if(answer.get(i) == N)
        ans++; answer.get(i) == N answer.get(i) answer.get answer i N 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 scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    
    ArrayList<Integer> answer = new ArrayList<Integer>();
    for(int i=0;i<=M;i++){
      answer.add(0);
    }
    
    for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    }
    int ans = 0;
    for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    
    ArrayList<Integer> answer = new ArrayList<Integer>();
    for(int i=0;i<=M;i++){
      answer.add(0);
    }
    
    for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    }
    int ans = 0;
    for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    }
    System.out.println(ans);
  }
} Main
import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    
    ArrayList<Integer> answer = new ArrayList<Integer>();
    for(int i=0;i<=M;i++){
      answer.add(0);
    }
    
    for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    }
    int ans = 0;
    for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    }
    System.out.println(ans);
  }
}
