import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> list1 = new ArrayList<>();

        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            list1.add(a);
        }

        for (int i = 1; i < n; i++) {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        }

        System.out.println(list1.size());
    }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner 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();
        List<Integer> list1 = new ArrayList<>();

        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            list1.add(a);
        }

        for (int i = 1; i < n; i++) {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        }

        System.out.println(list1.size());
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> list1 = new ArrayList<>();

        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            list1.add(a);
        }

        for (int i = 1; i < n; i++) {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        }

        System.out.println(list1.size());
    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> list1 = new ArrayList<>();

        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            list1.add(a);
        }

        for (int i = 1; i < n; i++) {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        }

        System.out.println(list1.size());
    } 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 List<Integer> list1 = new ArrayList<>(); list1 new ArrayList<>() int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            list1.add(a);
        } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
            int a = sc.nextInt();
            list1.add(a);
        } {
            int a = sc.nextInt();
            list1.add(a);
        } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc list1.add(a) list1.add list1 a for (int i = 1; i < n; i++) {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        } {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        } if (list1.isEmpty()) {
                break;
            } list1.isEmpty() list1.isEmpty list1 {
                break;
            } break; k = sc.nextInt() k sc.nextInt() sc.nextInt sc List<Integer> list2 = new ArrayList<>(); list2 new ArrayList<>() for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            } {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc if (list1.contains(a))
                    list2.add(a); list1.contains(a) list1.contains list1 a list2.add(a) list2.add list2 a list1 = list2 list1 list2 list2 = null list2 null System.out.println(list1.size()) System.out.println System.out System System.out list1.size() list1.size list1 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();
        List<Integer> list1 = new ArrayList<>();

        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            list1.add(a);
        }

        for (int i = 1; i < n; i++) {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        }

        System.out.println(list1.size());
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> list1 = new ArrayList<>();

        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            list1.add(a);
        }

        for (int i = 1; i < n; i++) {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        }

        System.out.println(list1.size());
    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> list1 = new ArrayList<>();

        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            list1.add(a);
        }

        for (int i = 1; i < n; i++) {
            if (list1.isEmpty()) {
                break;
            }
            k = sc.nextInt();
            List<Integer> list2 = new ArrayList<>();

            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                if (list1.contains(a))
                    list2.add(a);
            }
            list1 = list2;
            list2 = null;
        }

        System.out.println(list1.size());
    }
}
