import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[Integer.parseInt(sc.next())];
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        }
        int cnt = 0;
        for (int tmp : dish) {
            if (tmp == n) cnt++;
        }
        System.out.println(cnt);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[Integer.parseInt(sc.next())];
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        }
        int cnt = 0;
        for (int tmp : dish) {
            if (tmp == n) cnt++;
        }
        System.out.println(cnt);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[Integer.parseInt(sc.next())];
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        }
        int cnt = 0;
        for (int tmp : dish) {
            if (tmp == n) cnt++;
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[Integer.parseInt(sc.next())];
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        }
        int cnt = 0;
        for (int tmp : dish) {
            if (tmp == n) cnt++;
        }
        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] dish = new int[Integer.parseInt(sc.next())]; dish new int[Integer.parseInt(sc.next())] Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        } {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        } int num = Integer.parseInt(sc.next()); num Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            } int j = 0; int j = 0; j 0 j < num j num j++ j++ j {
                dish[Integer.parseInt(sc.next()) - 1]++;
            } {
                dish[Integer.parseInt(sc.next()) - 1]++;
            } dish[Integer.parseInt(sc.next()) - 1]++ dish[Integer.parseInt(sc.next()) - 1] dish Integer.parseInt(sc.next()) - 1 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc 1 int cnt = 0; cnt 0 for (int tmp : dish) {
            if (tmp == n) cnt++;
        } int tmp dish {
            if (tmp == n) cnt++;
        } {
            if (tmp == n) cnt++;
        } if (tmp == n) cnt++; tmp == n tmp n cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[Integer.parseInt(sc.next())];
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        }
        int cnt = 0;
        for (int tmp : dish) {
            if (tmp == n) cnt++;
        }
        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[Integer.parseInt(sc.next())];
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        }
        int cnt = 0;
        for (int tmp : dish) {
            if (tmp == n) cnt++;
        }
        System.out.println(cnt);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[Integer.parseInt(sc.next())];
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        }
        int cnt = 0;
        for (int tmp : dish) {
            if (tmp == n) cnt++;
        }
        System.out.println(cnt);
    }
}
