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

ab = [list(map(int, input().split())) for _ in range(n)]

dp = [0]*m

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

ab = [list(map(int, input().split())) for _ in range(n)]

dp = [0]*m

for i in range(n):
    for j in range(ab[i][0]):
        k = ab[i][j+1]
        dp[k-1] +=1
        
print(dp.count(n))