N, M = map(int, input().split())
A = []
for _ in range(N):
    s = list(map(int, input().split()))
    k = s[0]
    A.append(s[1:])

foods = [0] * M
for row in A:
    for a in row:
        foods[a-1] += 1
count = 0
for f in foods:
    if f == N:
        count += 1
print(count)
 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = [] A [] for _ in range(N):
    s = list(map(int, input().split()))
    k = s[0]
    A.append(s[1:]) _ range(N) range N s = list(map(int, input().split())) s list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k = s[0] k s[0] s 0 A.append(s[1:]) A.append A append s[1:] s 1: 1 foods = [0] * M foods [0] * M [0] 0 M for row in A:
    for a in row:
        foods[a-1] += 1 row A for a in row:
        foods[a-1] += 1 a row foods[a-1] += 1 foods[a-1] foods a-1 a 1 1 count = 0 count 0 for f in foods:
    if f == N:
        count += 1 f foods if f == N:
        count += 1 f == N f N count += 1 count 1 print(count) print count count += 1 1 count M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N foods = [0] * M [0] * M foods count = 0 0 count A = [] [] A k = s[0] s[0] k s = list(map(int, input().split())) list(map(int, input().split())) s
N, M = map(int, input().split())
A = []
for _ in range(N):
    s = list(map(int, input().split()))
    k = s[0]
    A.append(s[1:])

foods = [0] * M
for row in A:
    for a in row:
        foods[a-1] += 1
count = 0
for f in foods:
    if f == N:
        count += 1
print(count)

