#!/usr/bin/python

# coding: UTF-8

n,m = list(map(int,input().split()))



res = [0 for _ in range(m)]



for i in range(n):

  for j in list(map(int,input().split()))[1:]:

    res[j-1] += 1



print((res.count(n)))
#!/usr/bin/python

# coding: UTF-8

n,m = list(map(int,input().split()))



res = [0 for _ in range(m)]



for i in range(n):

  for j in list(map(int,input().split()))[1:]:

    res[j-1] += 1



print((sum([res[i]==n for i in range(m)])))
#!/usr/bin/python
# coding: UTF-8
n, m = list(map(int, input().split()))
res = [0 for _ in range(m)]
for i in range(n):
    for j in list(map(int, input().split()))[1:]:
        res[j - 1] += 1
print((res.count(n)))

#!/usr/bin/python
# coding: UTF-8
n, m = list(map(int, input().split()))
res = [0 for _ in range(m)]
for i in range(n):
    for j in list(map(int, input().split()))[1:]:
        res[j - 1] += 1
print((sum([res[i] == n for i in range(m)])))

-print((res.count(n))) +print((sum([res[i] == n for i in range(m)])))