//package Beginner118;

import java.io.*;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            set.add(s.nextInt());
        }
        for (int i = 1; i < n; i++) {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        }
        System.out.println(set.size());
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            set.add(s.nextInt());
        }
        for (int i = 1; i < n; i++) {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        }
        System.out.println(set.size());
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            set.add(s.nextInt());
        }
        for (int i = 1; i < n; i++) {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        }
        System.out.println(set.size());
    } main {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            set.add(s.nextInt());
        }
        for (int i = 1; i < n; i++) {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        }
        System.out.println(set.size());
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int m = s.nextInt(); m s.nextInt() s.nextInt s int k = s.nextInt(); k s.nextInt() s.nextInt s HashSet<Integer> set = new HashSet<>(); set new HashSet<>() for (int i = 0; i < k; i++) {
            set.add(s.nextInt());
        } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
            set.add(s.nextInt());
        } {
            set.add(s.nextInt());
        } set.add(s.nextInt()) set.add set s.nextInt() s.nextInt s for (int i = 1; i < n; i++) {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        } {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        } k = s.nextInt() k s.nextInt() s.nextInt s HashSet<Integer> set1 = new HashSet<>(); set1 new HashSet<>() for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                set1.add(s.nextInt());
            } {
                set1.add(s.nextInt());
            } set1.add(s.nextInt()) set1.add set1 s.nextInt() s.nextInt s set.retainAll(set1) set.retainAll set set1 System.out.println(set.size()) System.out.println System.out System System.out set.size() set.size set String[] args args public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            set.add(s.nextInt());
        }
        for (int i = 1; i < n; i++) {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        }
        System.out.println(set.size());
    }
} public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            set.add(s.nextInt());
        }
        for (int i = 1; i < n; i++) {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        }
        System.out.println(set.size());
    }
} Main
//package Beginner118;

import java.io.*;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            set.add(s.nextInt());
        }
        for (int i = 1; i < n; i++) {
            k = s.nextInt();
            HashSet<Integer> set1 = new HashSet<>();
            for (int j = 0; j < k; j++) {
                set1.add(s.nextInt());
            }
            set.retainAll(set1);
        }
        System.out.println(set.size());
    }
}
