object Main {
    def main(args: Array[String]) {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        val m = sc.nextInt
        var a = new Array[Int](m);
        for (i <- 0 to n - 1) {
            val k = sc.nextInt
            for (j <- 0 to k - 1) {
                val ii = sc.nextInt
                a.apply(ii - 1) += 1
            } 
        }
        var ans = 0;
        for (i <- 0 to m - 1) {
            if (a.apply(i) == n) {
                ans += 1
            }
        }
        println(ans)
    }
}