import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    cnt = [0] * m
    for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
    print(cnt.count(n))


if __name__ == '__main__':
    main() import sys sys stdin = sys.stdin stdin sys.stdin sys stdin def ns(): return stdin.readline().rstrip() ns def ni(): return int(stdin.readline().rstrip()) ni def nm(): return map(int, stdin.readline().split()) nm def nl(): return list(map(int, stdin.readline().split())) nl def main():
    n, m = nm()
    cnt = [0] * m
    for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
    print(cnt.count(n)) main n, m = nm() n nm() nm m cnt = [0] * m cnt [0] * m [0] 0 m for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
     i range(n) range n k, *A = nm() k nm() nm *A A for a in A:
            cnt[a - 1] += 1
     a A cnt[a - 1] += 1 cnt[a - 1] cnt a - 1 a 1 1 print(cnt.count(n)) print cnt.count(n) cnt.count cnt count n if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def nl(): return list(map(int, stdin.readline().split())) def nl(): return list(map(int, stdin.readline().split())) nl def ni(): return int(stdin.readline().rstrip()) def ni(): return int(stdin.readline().rstrip()) ni stdin = sys.stdin sys.stdin stdin def main():
    n, m = nm()
    cnt = [0] * m
    for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
    print(cnt.count(n)) def main():
    n, m = nm()
    cnt = [0] * m
    for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
    print(cnt.count(n)) main def ns(): return stdin.readline().rstrip() def ns(): return stdin.readline().rstrip() ns def nm(): return map(int, stdin.readline().split()) def nm(): return map(int, stdin.readline().split()) nm
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    cnt = [0] * m
    for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
    print(cnt.count(n))


if __name__ == '__main__':
    main()
