import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    }
  }
} import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args) {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    }
  }
} Main public static void main(String[] args) {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    }
  } main {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    }
  } try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    } {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    } Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int numPersons = scanner.nextInt(); numPersons scanner.nextInt() scanner.nextInt scanner scanner.nextInt() scanner.nextInt scanner Map<Integer, Integer> foods = new HashMap<>(); foods new HashMap<>() for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      } int personIndex = 0; int personIndex = 0; personIndex 0 personIndex < numPersons personIndex numPersons personIndex++ personIndex++ personIndex {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      } {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      } int numFoods = scanner.nextInt(); numFoods scanner.nextInt() scanner.nextInt scanner for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        } int foodIndex = 0; int foodIndex = 0; foodIndex 0 foodIndex < numFoods foodIndex numFoods foodIndex++ foodIndex++ foodIndex {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        } {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        } Integer food = scanner.nextInt(); food scanner.nextInt() scanner.nextInt scanner if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          } foods.containsKey(food) foods.containsKey foods food {
            foods.put(food, foods.get(food) + 1);
          } foods.put(food, foods.get(food) + 1) foods.put foods food foods.get(food) + 1 foods.get(food) foods.get foods food 1 {
            foods.put(food, 1);
          } foods.put(food, 1) foods.put foods food 1 int count = 0; count 0 for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      } Integer food foods.keySet() foods.keySet foods {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      } {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      } if (foods.get(food).equals(numPersons)) {
          count++;
        } foods.get(food).equals(numPersons) foods.get(food).equals foods.get(food) foods.get foods food numPersons {
          count++;
        } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
  public static void main(String[] args) {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    }
  }
} public class Main{
  public static void main(String[] args) {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    }
  }
} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    }
  }
}