n,m=map(int,input().split())
ans={i for i in range(1,m+1)}
for i in range(n):
    a=[int(i) for i in input().split()]
    a=a[1:]
    ans=ans&set(a)
print(len(list(ans))) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m i for i in range(1,m+1) for i in range(1,m+1) i range(1,m+1) range 1 m+1 m 1 for i in range(1,m+1) i ans={i for i in range(1,m+1)} ans for i in range(n):
    a=[int(i) for i in input().split()]
    a=a[1:]
    ans=ans&set(a) i range(n) range n int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a=[int(i) for i in input().split()] a [int(i) for i in input().split()] a=a[1:] a a[1:] a 1: 1 ans=ans&set(a) ans ans&set(a) ans set(a) set a print(len(list(ans))) print len(list(ans)) len list(ans) list ans n,m=map(int,input().split()) map(int,input().split()) n a=[int(i) for i in input().split()] [int(i) for i in input().split()] a ans=ans&set(a) ans&set(a) ans m=map(int,input().split()) map(int,input().split()) m ans={i for i in range(1,m+1)} ans a=a[1:] a[1:] a
n,m=map(int,input().split())
ans={i for i in range(1,m+1)}
for i in range(n):
    a=[int(i) for i in input().split()]
    a=a[1:]
    ans=ans&set(a)
print(len(list(ans)))