import 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[][] A = new int[N][];
        int[] bit = new int[N];
        for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        }
        int res = bit[0];
        for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        }
        System.out.println(Integer.bitCount(res));
        sc.close();
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] A = new int[N][];
        int[] bit = new int[N];
        for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        }
        int res = bit[0];
        for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        }
        System.out.println(Integer.bitCount(res));
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] A = new int[N][];
        int[] bit = new int[N];
        for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        }
        int res = bit[0];
        for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        }
        System.out.println(Integer.bitCount(res));
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] A = new int[N][];
        int[] bit = new int[N];
        for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        }
        int res = bit[0];
        for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        }
        System.out.println(Integer.bitCount(res));
        sc.close();
    } 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[][] A = new int[N][]; A new int[N][] N int[] bit = new int[N]; bit new int[N] N for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        } int i = 0; int i = 0; i 0 i < A.length i A.length A A.length i++ i++ i {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        } {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc A[i] = new int[K] A[i] A i new int[K] K for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            } int j = 0; int j = 0; j 0 j < A[i].length j A[i].length A[i] A i A[i].length j++ j++ j {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            } {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            } A[i][j] = sc.nextInt() A[i][j] A[i] A i j sc.nextInt() sc.nextInt sc bit[i] |= (1 << (A[i][j] - 1)) bit[i] bit i (1 << (A[i][j] - 1)) 1 (A[i][j] - 1) A[i][j] A[i] A i j 1 int res = bit[0]; res bit[0] bit 0 for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        } int i = 1; int i = 1; i 1 i < bit.length i bit.length bit bit.length i++ i++ i {
            res &= bit[i];
        } {
            res &= bit[i];
        } res &= bit[i] res bit[i] bit i System.out.println(Integer.bitCount(res)) System.out.println System.out System System.out Integer.bitCount(res) Integer.bitCount Integer res sc.close() sc.close sc 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[][] A = new int[N][];
        int[] bit = new int[N];
        for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        }
        int res = bit[0];
        for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        }
        System.out.println(Integer.bitCount(res));
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] A = new int[N][];
        int[] bit = new int[N];
        for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        }
        int res = bit[0];
        for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        }
        System.out.println(Integer.bitCount(res));
        sc.close();
    }
} Main
import 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[][] A = new int[N][];
        int[] bit = new int[N];
        for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        }
        int res = bit[0];
        for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        }
        System.out.println(Integer.bitCount(res));
        sc.close();
    }
}