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[][] suki = new int[n][m];
    for(int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    }
    int ans = 0;
    for(int j = 0; j < m; j++) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) 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[][] suki = new int[n][m];
    for(int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    }
    int ans = 0;
    for(int j = 0; j < m; j++) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) 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[][] suki = new int[n][m];
    for(int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    }
    int ans = 0;
    for(int j = 0; j < m; j++) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) ans++; 
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] suki = new int[n][m];
    for(int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    }
    int ans = 0;
    for(int j = 0; j < m; j++) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) 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[][] suki = new int[n][m]; suki new int[n][m] n m for(int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    } 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++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    } {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      } {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      } int r = sc.nextInt() - 1; r sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 suki[i][r]++ suki[i][r] suki[i] suki i r int ans = 0; ans 0 for(int j = 0; j < m; j++) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) ans++; 
    } int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) ans++; 
    } {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) ans++; 
    } int p = 1; p 1 for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        if(suki[i][j] == 0) p = 0;
      } {
        if(suki[i][j] == 0) p = 0;
      } if(suki[i][j] == 0) p = 0; suki[i][j] == 0 suki[i][j] suki[i] suki i j 0 p = 0 p 0 if(p == 1) ans++; p == 1 p 1 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[][] suki = new int[n][m];
    for(int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    }
    int ans = 0;
    for(int j = 0; j < m; j++) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) 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[][] suki = new int[n][m];
    for(int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    }
    int ans = 0;
    for(int j = 0; j < m; j++) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) 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[][] suki = new int[n][m];
    for(int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for(int j = 0; j < k; j++) {
        int r = sc.nextInt() - 1;
        suki[i][r]++;  
      }
    }
    int ans = 0;
    for(int j = 0; j < m; j++) {
      int p = 1;
      for(int i = 0; i < n; i++) {
        if(suki[i][j] == 0) p = 0;
      }
      if(p == 1) ans++; 
    }
    System.out.println(ans);
  }
}