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[] dic = new int[m+1];

        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        }

        int sum = 0;
        for (int i : dic) {
            if (i == n) sum++;
        }
        System.out.println(sum);
    }
} 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[] dic = new int[m+1];

        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        }

        int sum = 0;
        for (int i : dic) {
            if (i == n) sum++;
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] dic = new int[m+1];

        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        }

        int sum = 0;
        for (int i : dic) {
            if (i == n) sum++;
        }
        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] dic = new int[m+1];

        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        }

        int sum = 0;
        for (int i : dic) {
            if (i == n) sum++;
        }
        System.out.println(sum);
    } 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[] dic = new int[m+1]; dic new int[m+1] m+1 m 1 sc.nextLine() sc.nextLine sc for (int i = 0; i < n; i++) {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        } {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        } String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc boolean flag = false; flag false for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            } String s line.split(" ") line.split line " " {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            } {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            } if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                } flag {
                    dic[Integer.valueOf(s).intValue()]++;
                } dic[Integer.valueOf(s).intValue()]++ dic[Integer.valueOf(s).intValue()] dic Integer.valueOf(s).intValue() Integer.valueOf(s).intValue Integer.valueOf(s) Integer.valueOf Integer s {
                    flag = true;
                } flag = true flag true int sum = 0; sum 0 for (int i : dic) {
            if (i == n) sum++;
        } int i dic {
            if (i == n) sum++;
        } {
            if (i == n) sum++;
        } if (i == n) sum++; i == n i n sum++ sum System.out.println(sum) System.out.println System.out System System.out sum 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[] dic = new int[m+1];

        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        }

        int sum = 0;
        for (int i : dic) {
            if (i == n) sum++;
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] dic = new int[m+1];

        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        }

        int sum = 0;
        for (int i : dic) {
            if (i == n) sum++;
        }
        System.out.println(sum);
    }
} 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[] dic = new int[m+1];

        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String line = sc.nextLine();

            boolean flag = false;
            for (String s : line.split(" ")) {
                if (flag) {
                    dic[Integer.valueOf(s).intValue()]++;
                } else {
                    flag = true;
                }

            }
        }

        int sum = 0;
        for (int i : dic) {
            if (i == n) sum++;
        }
        System.out.println(sum);
    }
}