n,m = map(int, input().split())

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        favorite = survey[j]
        cnt[favorite - 1] += 1

print(cnt.count(n)) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m cnt = [0]*m cnt [0]*m [0] 0 m for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        favorite = survey[j]
        cnt[favorite - 1] += 1 i range(n) range n survey = list(map(int, input().split())) survey list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k = survey[0] k survey[0] survey 0 for j in range(1,k+1):
        favorite = survey[j]
        cnt[favorite - 1] += 1 j range(1,k+1) range 1 k+1 k 1 favorite = survey[j] favorite survey[j] survey j cnt[favorite - 1] += 1 cnt[favorite - 1] cnt favorite - 1 favorite 1 1 print(cnt.count(n)) print cnt.count(n) cnt.count cnt count n survey = list(map(int, input().split())) list(map(int, input().split())) survey m = map(int, input().split()) map(int, input().split()) m n,m = map(int, input().split()) map(int, input().split()) n favorite = survey[j] survey[j] favorite cnt = [0]*m [0]*m cnt k = survey[0] survey[0] k
n,m = map(int, input().split())

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        favorite = survey[j]
        cnt[favorite - 1] += 1

print(cnt.count(n))