#B
n, m = map(int, input().split())
k = []
a = []
for i in range(n):
    l = list(map(int, input().split()))
    k.append(l[0])
    a.append(l[1:l[0] + 1])
# print(k, a)
ans = [0] * m
for i in range(n):
    b=k[i]
    for j in range(b):
        ans[a[i][j]-1] += 1
# print(ans)
count = 0
for i in range(m):
    if ans[i] == n:
        count += 1
print(count) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m k = [] k [] a = [] a [] for i in range(n):
    l = list(map(int, input().split()))
    k.append(l[0])
    a.append(l[1:l[0] + 1])
# print(k, a) i range(n) range n l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k.append(l[0]) k.append k append l[0] l 0 a.append(l[1:l[0] + 1]) a.append a append l[1:l[0] + 1] l 1:l[0] + 1 1 l[0] + 1 l[0] l 0 1 ans = [0] * m ans [0] * m [0] 0 m for i in range(n):
    b=k[i]
    for j in range(b):
        ans[a[i][j]-1] += 1
# print(ans) i range(n) range n b=k[i] b k[i] k i for j in range(b):
        ans[a[i][j]-1] += 1
# print(ans) j range(b) range b ans[a[i][j]-1] += 1 ans[a[i][j]-1] ans a[i][j]-1 a[i][j] [i] a i j 1 1 count = 0 count 0 for i in range(m):
    if ans[i] == n:
        count += 1 i range(m) range m if ans[i] == n:
        count += 1 ans[i] == n ans[i] ans i n count += 1 count 1 print(count) print count count = 0 0 count k = [] [] k a = [] [] a ans = [0] * m [0] * m ans n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m b=k[i] k[i] b count += 1 1 count l = list(map(int, input().split())) list(map(int, input().split())) l
#B
n, m = map(int, input().split())
k = []
a = []
for i in range(n):
    l = list(map(int, input().split()))
    k.append(l[0])
    a.append(l[1:l[0] + 1])
# print(k, a)
ans = [0] * m
for i in range(n):
    b=k[i]
    for j in range(b):
        ans[a[i][j]-1] += 1
# print(ans)
count = 0
for i in range(m):
    if ans[i] == n:
        count += 1
print(count)