import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

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

        int[] food = new int[m];
        for (int i=0; i<m; i++) food[i] = n;

        for (int i=0; i<n; i++) {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        }

        int count = 0;
        for (int i=0; i<m; i++) {
            if (food[i] == 0) count++;
        }

        System.out.println(count);

        in.close();
    }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();

        int[] food = new int[m];
        for (int i=0; i<m; i++) food[i] = n;

        for (int i=0; i<n; i++) {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        }

        int count = 0;
        for (int i=0; i<m; i++) {
            if (food[i] == 0) count++;
        }

        System.out.println(count);

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

        int[] food = new int[m];
        for (int i=0; i<m; i++) food[i] = n;

        for (int i=0; i<n; i++) {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        }

        int count = 0;
        for (int i=0; i<m; i++) {
            if (food[i] == 0) count++;
        }

        System.out.println(count);

        in.close();
    } main {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();

        int[] food = new int[m];
        for (int i=0; i<m; i++) food[i] = n;

        for (int i=0; i<n; i++) {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        }

        int count = 0;
        for (int i=0; i<m; i++) {
            if (food[i] == 0) count++;
        }

        System.out.println(count);

        in.close();
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int m = in.nextInt(); m in.nextInt() in.nextInt in int[] food = new int[m]; food new int[m] m for (int i=0; i<m; i++) food[i] = n; int i=0; int i=0; i 0 i<m i m i++ i++ i food[i] = n; food[i] = n food[i] food i n for (int i=0; i<n; i++) {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        } {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        } int k = in.nextInt(); k in.nextInt() in.nextInt in for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            } int j=0; int j=0; j 0 j<k j k j++ j++ j {
                int a = in.nextInt();
                food[a-1]--;
            } {
                int a = in.nextInt();
                food[a-1]--;
            } int a = in.nextInt(); a in.nextInt() in.nextInt in food[a-1]-- food[a-1] food a-1 a 1 int count = 0; count 0 for (int i=0; i<m; i++) {
            if (food[i] == 0) count++;
        } int i=0; int i=0; i 0 i<m i m i++ i++ i {
            if (food[i] == 0) count++;
        } {
            if (food[i] == 0) count++;
        } if (food[i] == 0) count++; food[i] == 0 food[i] food i 0 count++ count System.out.println(count) System.out.println System.out System System.out count in.close() in.close in String[] args args
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

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

        int[] food = new int[m];
        for (int i=0; i<m; i++) food[i] = n;

        for (int i=0; i<n; i++) {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        }

        int count = 0;
        for (int i=0; i<m; i++) {
            if (food[i] == 0) count++;
        }

        System.out.println(count);

        in.close();
    }
}