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

info = [input().split() for i in range(n)]
achi = []
for i in range(m):
    achi.append(0)

# print(info[0][0])

for i in range(n):
    for j in range(int(info[i][0])):
        num = int(info[i][j+1])
        achi[num-1] += 1


print(achi.count(n)) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m input().split() for i in range(n) for i in range(n) i range(n) range n for i in range(n) input().split() ().split () input split info = [input().split() for i in range(n)] info [input().split() for i in range(n)] achi = [] achi [] for i in range(m):
    achi.append(0)

# print(info[0][0]) i range(m) range m achi.append(0) achi.append achi append 0 for i in range(n):
    for j in range(int(info[i][0])):
        num = int(info[i][j+1])
        achi[num-1] += 1 i range(n) range n for j in range(int(info[i][0])):
        num = int(info[i][j+1])
        achi[num-1] += 1 j range(int(info[i][0])) range int(info[i][0]) int info[i][0] [i] info i 0 num = int(info[i][j+1]) num int(info[i][j+1]) int info[i][j+1] [i] info i j+1 j 1 achi[num-1] += 1 achi[num-1] achi num-1 num 1 1 print(achi.count(n)) print achi.count(n) achi.count achi count n m = map(int,input().split()) map(int,input().split()) m achi = [] [] achi num = int(info[i][j+1]) int(info[i][j+1]) num n,m = map(int,input().split()) map(int,input().split()) n info = [input().split() for i in range(n)] [input().split() for i in range(n)] info
n,m = map(int,input().split())

info = [input().split() for i in range(n)]
achi = []
for i in range(m):
    achi.append(0)

# print(info[0][0])

for i in range(n):
    for j in range(int(info[i][0])):
        num = int(info[i][j+1])
        achi[num-1] += 1


print(achi.count(n))