import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        int N = 0;
        int M = 0;
        int[] result = new int[30];

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        int N = 0;
        int M = 0;
        int[] result = new int[30];

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        int N = 0;
        int M = 0;
        int[] result = new int[30];

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    } main {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        int N = 0;
        int M = 0;
        int[] result = new int[30];

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int count = 0; count 0 int N = 0; N 0 int M = 0; M 0 int[] result = new int[30]; result new int[30] 30 while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        } scan.hasNext() scan.hasNext scan {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        } if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            } count == 0 count 0 {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            } N = scan.nextInt() N scan.nextInt() scan.nextInt scan M = scan.nextInt() M scan.nextInt() scan.nextInt scan scan.nextLine() scan.nextLine scan count++ count continue; String str = scan.nextLine(); str scan.nextLine() scan.nextLine scan String[] splited = str.split(" "); splited str.split(" ") str.split str " " for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            } int j = 1; int j = 1; j 1 j <= Integer.parseInt(splited[0]) j Integer.parseInt(splited[0]) Integer.parseInt Integer splited[0] splited 0 j++ j++ j {
                result[Integer.parseInt(splited[j]) - 1]++;
            } {
                result[Integer.parseInt(splited[j]) - 1]++;
            } result[Integer.parseInt(splited[j]) - 1]++ result[Integer.parseInt(splited[j]) - 1] result Integer.parseInt(splited[j]) - 1 Integer.parseInt(splited[j]) Integer.parseInt Integer splited[j] splited j 1 if (++count > N) {
                break;
            } ++count > N ++count count N {
                break;
            } break; int resultCount = 0; resultCount 0 for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        } int r result {
            if (r == N) {
                resultCount++;
            }
        } {
            if (r == N) {
                resultCount++;
            }
        } if (r == N) {
                resultCount++;
            } r == N r N {
                resultCount++;
            } resultCount++ resultCount System.out.print(resultCount) System.out.print System.out System System.out resultCount String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        int N = 0;
        int M = 0;
        int[] result = new int[30];

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        int N = 0;
        int M = 0;
        int[] result = new int[30];

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        int N = 0;
        int M = 0;
        int[] result = new int[30];

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    }
}
