import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    }
  }

  private static boolean hasElem(String[] results, int num) {
    for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    }
    return true;
  }

  private static boolean hasWord(String[] words, int num) {
    for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    }
    return false;
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    }
  }

  private static boolean hasElem(String[] results, int num) {
    for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    }
    return true;
  }

  private static boolean hasWord(String[] words, int num) {
    for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    }
    return false;
  }
} Main public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    }
  } main {
    try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    }
  } try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    } {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc String[] results = new String[n]; results new String[n] n for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        results[i] = sc.nextLine().substring(2);
      } {
        results[i] = sc.nextLine().substring(2);
      } results[i] = sc.nextLine().substring(2) results[i] results i sc.nextLine().substring(2) sc.nextLine().substring sc.nextLine() sc.nextLine sc 2 int sum = 0; sum 0 for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      } int i = 1; int i = 1; i 1 i <= m i m i++ i++ i {
        if (hasElem(results, i)) {
          sum++;
        }
      } {
        if (hasElem(results, i)) {
          sum++;
        }
      } if (hasElem(results, i)) {
          sum++;
        } hasElem(results, i) hasElem results i {
          sum++;
        } sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args private static boolean hasElem(String[] results, int num) {
    for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    }
    return true;
  } hasElem {
    for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    }
    return true;
  } for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    } String result results {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    } {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    } String[] elems = result.split(" "); elems result.split(" ") result.split result " " if (hasWord(elems, num) == false) {
        return false;
      } hasWord(elems, num) == false hasWord(elems, num) hasWord elems num false {
        return false;
      } return false; false return true; true String[] results results int num num private static boolean hasWord(String[] words, int num) {
    for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    }
    return false;
  } hasWord {
    for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    }
    return false;
  } for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    } String word words {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    } {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    } if (word.equals(String.valueOf(num))) {
        return true;
      } word.equals(String.valueOf(num)) word.equals word String.valueOf(num) String.valueOf String num {
        return true;
      } return true; true return false; false String[] words words int num num public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    }
  }

  private static boolean hasElem(String[] results, int num) {
    for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    }
    return true;
  }

  private static boolean hasWord(String[] words, int num) {
    for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    }
    return false;
  }
} public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    }
  }

  private static boolean hasElem(String[] results, int num) {
    for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    }
    return true;
  }

  private static boolean hasWord(String[] words, int num) {
    for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    }
    return false;
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    }
  }

  private static boolean hasElem(String[] results, int num) {
    for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    }
    return true;
  }

  private static boolean hasWord(String[] words, int num) {
    for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    }
    return false;
  }
}