n,m = map(int,input().split())
l = []
for _ in range(n):
    a = list(map(int,input().split()))
    l.append(a)

b = []

for i in range(n):
    for j in range(1,l[i][0]+1):
        b.append(l[i][j])

ans = 0
for k in range(1,m+1):
    cnt = b.count(k)
    if cnt == n:
        ans += 1

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

b = []

for i in range(n):
    for j in range(1,l[i][0]+1):
        b.append(l[i][j])

ans = 0
for k in range(1,m+1):
    cnt = b.count(k)
    if cnt == n:
        ans += 1

print(ans)