import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int[] ar = new int[M];
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (ar[i] == N) ans++;
        }
        
        out.println(ans);
        
        out.flush();
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int[] ar = new int[M];
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (ar[i] == N) ans++;
        }
        
        out.println(ans);
        
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int[] ar = new int[M];
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (ar[i] == N) ans++;
        }
        
        out.println(ans);
        
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int[] ar = new int[M];
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (ar[i] == N) ans++;
        }
        
        out.println(ans);
        
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) final int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc final int M = Integer.parseInt(sc.next()); M Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] ar = new int[M]; ar new int[M] M int ans = 0; ans 0 for (int i = 0; i < N; i++) {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        } {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        } int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            } {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            } int index = Integer.parseInt(sc.next()); index Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc ar[index - 1]++ ar[index - 1] ar index - 1 index 1 for (int i = 0; i < M; i++) {
            if (ar[i] == N) ans++;
        } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
            if (ar[i] == N) ans++;
        } {
            if (ar[i] == N) ans++;
        } if (ar[i] == N) ans++; ar[i] == N ar[i] ar i N ans++ ans out.println(ans) out.println out ans out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int[] ar = new int[M];
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (ar[i] == N) ans++;
        }
        
        out.println(ans);
        
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int[] ar = new int[M];
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (ar[i] == N) ans++;
        }
        
        out.println(ans);
        
        out.flush();
    }
} Main
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int[] ar = new int[M];
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int k = Integer.parseInt(sc.next());
            for (int j = 0; j < k; j++) {
                int index = Integer.parseInt(sc.next());
                ar[index - 1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (ar[i] == N) ans++;
        }
        
        out.println(ans);
        
        out.flush();
    }
}