import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) B solver = new B(); solver new B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        }

    } B public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        } solve {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        } int n = Integer.parseInt(in.next()); n Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int m = Integer.parseInt(in.next()); m Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int k[] = new int[n]; k new int[n] n int dishes[] = new int[m]; dishes new int[m] m for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            } {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            } k[i] = Integer.parseInt(in.next()) k[i] k i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                } int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                } {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                } dishes[Integer.parseInt(in.next()) - 1]++ dishes[Integer.parseInt(in.next()) - 1] dishes Integer.parseInt(in.next()) - 1 Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in 1 int ans = 0; ans 0 for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                if (dishes[i] == n) ans++;
            } {
                if (dishes[i] == n) ans++;
            } if (dishes[i] == n) ans++; dishes[i] == n dishes[i] dishes i n ans++ ans out.println(ans) out.println out ans int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        }

    }
}

