from collections import Counter
N, M = map(int, input().split())
c = Counter()
for i in range(N):
    K, *A = list(map(int, input().split()))
    c.update(A)
r = 0
for k, v in c.items():
    if v == N:
        r += 1
print(r) from collections import Counter N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M c = Counter() c Counter() Counter for i in range(N):
    K, *A = list(map(int, input().split()))
    c.update(A) i range(N) range N K, *A = list(map(int, input().split())) K list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split *A A c.update(A) c.update c update A r = 0 r 0 for k, v in c.items():
    if v == N:
        r += 1 k v c.items() c.items c items if v == N:
        r += 1 v == N v N r += 1 r 1 print(r) print r c = Counter() Counter() c K, *A = list(map(int, input().split())) list(map(int, input().split())) K N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M r = 0 0 r r += 1 1 r
from collections import Counter
N, M = map(int, input().split())
c = Counter()
for i in range(N):
    K, *A = list(map(int, input().split()))
    c.update(A)
r = 0
for k, v in c.items():
    if v == N:
        r += 1
print(r)
