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[] k = new int[n];
        int[][] a = new int[n][m];
        int[] count = new int[m];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        }
        for (int i = 0; i < m; i++) {
            if (count[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
} 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[] k = new int[n];
        int[][] a = new int[n][m];
        int[] count = new int[m];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        }
        for (int i = 0; i < m; i++) {
            if (count[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[][] a = new int[n][m];
        int[] count = new int[m];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        }
        for (int i = 0; i < m; i++) {
            if (count[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[][] a = new int[n][m];
        int[] count = new int[m];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        }
        for (int i = 0; i < m; i++) {
            if (count[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[][] a = new int[n][m]; a new int[n][m] n m int[] count = new int[m]; count new int[m] m int ans = 0; ans 0 for (int i = 0; i < m; i++) {
            count[i] = 0;
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            count[i] = 0;
        } {
            count[i] = 0;
        } count[i] = 0 count[i] count i 0 for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        } {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        } k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            } int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
                a[i][j] = sc.nextInt();
            } {
                a[i][j] = sc.nextInt();
            } a[i][j] = sc.nextInt() a[i][j] a[i] a i j sc.nextInt() sc.nextInt sc for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        } {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        } for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            } int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
                count[a[i][j] - 1]++;
            } {
                count[a[i][j] - 1]++;
            } count[a[i][j] - 1]++ count[a[i][j] - 1] count a[i][j] - 1 a[i][j] a[i] a i j 1 for (int i = 0; i < m; i++) {
            if (count[i] == n)
                ans++;
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            if (count[i] == n)
                ans++;
        } {
            if (count[i] == n)
                ans++;
        } if (count[i] == n)
                ans++; count[i] == n count[i] count 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[][] a = new int[n][m];
        int[] count = new int[m];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        }
        for (int i = 0; i < m; i++) {
            if (count[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[][] a = new int[n][m];
        int[] count = new int[m];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        }
        for (int i = 0; i < m; i++) {
            if (count[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
} 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[] k = new int[n];
        int[][] a = new int[n][m];
        int[] count = new int[m];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        }
        for (int i = 0; i < m; i++) {
            if (count[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
}