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 liked[] = new int[31];
        for (int i = 0; i < N; ++i) {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        }
        int res = 0;
        for (int i = 0; i < 31; ++i) {
            if (liked[i] == N) ++res;
        }
        System.out.println(res);
    }
} 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 liked[] = new int[31];
        for (int i = 0; i < N; ++i) {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        }
        int res = 0;
        for (int i = 0; i < 31; ++i) {
            if (liked[i] == N) ++res;
        }
        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int liked[] = new int[31];
        for (int i = 0; i < N; ++i) {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        }
        int res = 0;
        for (int i = 0; i < 31; ++i) {
            if (liked[i] == N) ++res;
        }
        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int liked[] = new int[31];
        for (int i = 0; i < N; ++i) {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        }
        int res = 0;
        for (int i = 0; i < 31; ++i) {
            if (liked[i] == N) ++res;
        }
        System.out.println(res);
    } 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 liked[] = new int[31]; liked new int[31] 31 for (int i = 0; i < N; ++i) {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        } int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        } {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            } int j = 0; int j = 0; j 0 j < K j K ++j ++j j {
                int A = sc.nextInt();
                ++liked[A];
            } {
                int A = sc.nextInt();
                ++liked[A];
            } int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc ++liked[A] liked[A] liked A int res = 0; res 0 for (int i = 0; i < 31; ++i) {
            if (liked[i] == N) ++res;
        } int i = 0; int i = 0; i 0 i < 31 i 31 ++i ++i i {
            if (liked[i] == N) ++res;
        } {
            if (liked[i] == N) ++res;
        } if (liked[i] == N) ++res; liked[i] == N liked[i] liked i N ++res res System.out.println(res) System.out.println System.out System System.out res 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 liked[] = new int[31];
        for (int i = 0; i < N; ++i) {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        }
        int res = 0;
        for (int i = 0; i < 31; ++i) {
            if (liked[i] == N) ++res;
        }
        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int liked[] = new int[31];
        for (int i = 0; i < N; ++i) {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        }
        int res = 0;
        for (int i = 0; i < 31; ++i) {
            if (liked[i] == N) ++res;
        }
        System.out.println(res);
    }
} 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 liked[] = new int[31];
        for (int i = 0; i < N; ++i) {
            int K = sc.nextInt();
            for (int j = 0; j < K; ++j) {
                int A = sc.nextInt();
                ++liked[A];
            }
        }
        int res = 0;
        for (int i = 0; i < 31; ++i) {
            if (liked[i] == N) ++res;
        }
        System.out.println(res);
    }
}
