import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int n = scnr.nextInt();
      int m = scnr.nextInt();
      int[] likedFoods = new int[m];
      for (int i = 0; i < n; i++) {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      }
      int result = 0;
      for (int i = 0; i < m; i++) {
        if (likedFoods[i] == n) result++;
      }
      System.out.println(result);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int n = scnr.nextInt();
      int m = scnr.nextInt();
      int[] likedFoods = new int[m];
      for (int i = 0; i < n; i++) {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      }
      int result = 0;
      for (int i = 0; i < m; i++) {
        if (likedFoods[i] == n) result++;
      }
      System.out.println(result);
    }
} Main public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int n = scnr.nextInt();
      int m = scnr.nextInt();
      int[] likedFoods = new int[m];
      for (int i = 0; i < n; i++) {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      }
      int result = 0;
      for (int i = 0; i < m; i++) {
        if (likedFoods[i] == n) result++;
      }
      System.out.println(result);
    } main {
      Scanner scnr = new Scanner(System.in);
      int n = scnr.nextInt();
      int m = scnr.nextInt();
      int[] likedFoods = new int[m];
      for (int i = 0; i < n; i++) {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      }
      int result = 0;
      for (int i = 0; i < m; i++) {
        if (likedFoods[i] == n) result++;
      }
      System.out.println(result);
    } Scanner scnr = new Scanner(System.in); scnr new Scanner(System.in) int n = scnr.nextInt(); n scnr.nextInt() scnr.nextInt scnr int m = scnr.nextInt(); m scnr.nextInt() scnr.nextInt scnr int[] likedFoods = new int[m]; likedFoods new int[m] m for (int i = 0; i < n; i++) {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      } {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      } int k = scnr.nextInt(); k scnr.nextInt() scnr.nextInt scnr for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        } {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        } int food = scnr.nextInt(); food scnr.nextInt() scnr.nextInt scnr likedFoods[food-1]++ likedFoods[food-1] likedFoods food-1 food 1 int result = 0; result 0 for (int i = 0; i < m; i++) {
        if (likedFoods[i] == n) result++;
      } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
        if (likedFoods[i] == n) result++;
      } {
        if (likedFoods[i] == n) result++;
      } if (likedFoods[i] == n) result++; likedFoods[i] == n likedFoods[i] likedFoods i n result++ result System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int n = scnr.nextInt();
      int m = scnr.nextInt();
      int[] likedFoods = new int[m];
      for (int i = 0; i < n; i++) {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      }
      int result = 0;
      for (int i = 0; i < m; i++) {
        if (likedFoods[i] == n) result++;
      }
      System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int n = scnr.nextInt();
      int m = scnr.nextInt();
      int[] likedFoods = new int[m];
      for (int i = 0; i < n; i++) {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      }
      int result = 0;
      for (int i = 0; i < m; i++) {
        if (likedFoods[i] == n) result++;
      }
      System.out.println(result);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int n = scnr.nextInt();
      int m = scnr.nextInt();
      int[] likedFoods = new int[m];
      for (int i = 0; i < n; i++) {
        int k = scnr.nextInt();
        for (int j = 0; j < k; j++) {
          int food = scnr.nextInt();
          likedFoods[food-1]++;
        }
      }
      int result = 0;
      for (int i = 0; i < m; i++) {
        if (likedFoods[i] == n) result++;
      }
      System.out.println(result);
    }
}