
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();
        int[][] k = new int[n][m];
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        }
        int ans = 0;
        for (int j = 0 ; j < m ;j++) {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        }


        System.out.println(ans);
    }

} 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();
        int[][] k = new int[n][m];
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        }
        int ans = 0;
        for (int j = 0 ; j < m ;j++) {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        }


        System.out.println(ans);
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] k = new int[n][m];
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        }
        int ans = 0;
        for (int j = 0 ; j < m ;j++) {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        }


        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] k = new int[n][m];
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        }
        int ans = 0;
        for (int j = 0 ; j < m ;j++) {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        }


        System.out.println(ans);
    } 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 int[][] k = new int[n][m]; k new int[n][m] n m int[] a = new int[n]; a new int[n] n for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        } {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            } int j = 0 ; int j = 0 ; j 0 j < a[i] j a[i] a i j++ j++ j {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            } {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            } int x = sc.nextInt() - 1; x sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 k[i][x]++ k[i][x] k[i] k i x int ans = 0; ans 0 for (int j = 0 ; j < m ;j++) {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        } int j = 0 ; int j = 0 ; j 0 j < m j m j++ j++ j {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        } {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        } int c = 0; c 0 for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
                if (k[i][j] == 1) {
                    c++;
                }
            } {
                if (k[i][j] == 1) {
                    c++;
                }
            } if (k[i][j] == 1) {
                    c++;
                } k[i][j] == 1 k[i][j] k[i] k i j 1 {
                    c++;
                } c++ c if (c == n) {
                ans++;
            } c == n c n {
                ans++;
            } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans 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();
        int[][] k = new int[n][m];
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        }
        int ans = 0;
        for (int j = 0 ; j < m ;j++) {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        }


        System.out.println(ans);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] k = new int[n][m];
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        }
        int ans = 0;
        for (int j = 0 ; j < m ;j++) {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        }


        System.out.println(ans);
    }

} Main

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();
        int[][] k = new int[n][m];
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            for (int j = 0 ; j < a[i] ; j++) {
                int x = sc.nextInt() - 1;
                k[i][x]++;
            }
        }
        int ans = 0;
        for (int j = 0 ; j < m ;j++) {
            int c = 0;
            for (int i = 0 ; i < n ; i++) {
                if (k[i][j] == 1) {
                    c++;
                }
            }
            if (c == n) {
                ans++;
            }
        }


        System.out.println(ans);
    }

}
