import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] mm = new int[m];
        for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java import java.io.*; io.* 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[] k = new int[n];
        int[] mm = new int[m];
        for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] mm = new int[m];
        for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] mm = new int[m];
        for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        }
        System.out.println(ans);
    } 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[] k = new int[n]; k new int[n] n int[] mm = new int[m]; mm new int[m] m for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        } {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        } int kk = sc.nextInt(); kk sc.nextInt() sc.nextInt sc for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            } int j = 0; int j = 0; j 0 j < kk j kk j++ j++ j {
                mm[sc.nextInt() - 1]++;
            } {
                mm[sc.nextInt() - 1]++;
            } mm[sc.nextInt() - 1]++ mm[sc.nextInt() - 1] mm sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int ans = 0; ans 0 for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            if (mm[i] == n)
                ans++;
        } {
            if (mm[i] == n)
                ans++;
        } if (mm[i] == n)
                ans++; mm[i] == n mm[i] mm i n ans++ ans System.out.println(ans) System.out.println System.out System System.out ans 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[] k = new int[n];
        int[] mm = new int[m];
        for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] mm = new int[m];
        for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] mm = new int[m];
        for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
}