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:])
# print(A)
Aall = []
for e in A:
    Aall += e
# print(Aall)
ans = 0
for i in range(1, m + 1):
    if Aall.count(i) == n:
        ans += 1
print(ans) 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:])
# print(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:]) A.append A append L[1:] L 1: 1 Aall = [] Aall [] for e in A:
    Aall += e
# print(Aall) e A Aall += e Aall e ans = 0 ans 0 for i in range(1, m + 1):
    if Aall.count(i) == n:
        ans += 1 i range(1, m + 1) range 1 m + 1 m 1 if Aall.count(i) == n:
        ans += 1 Aall.count(i) == n Aall.count(i) Aall.count Aall count i n ans += 1 ans 1 print(ans) print ans Aall = [] [] Aall K = [] [] K m = map(int, input().split()) map(int, input().split()) m L = list(map(int, input().split())) list(map(int, input().split())) L ans += 1 1 ans ans = 0 0 ans Aall += e e Aall n, m = map(int, input().split()) map(int, input().split()) n A = [] [] A
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:])
# print(A)
Aall = []
for e in A:
    Aall += e
# print(Aall)
ans = 0
for i in range(1, m + 1):
    if Aall.count(i) == n:
        ans += 1
print(ans)
