n, m = input().split(" ")
n = int(n)
m = int(m)
k = []
for i in range(n):
    k.append([])
    tmp = input().split(" ")
    for j in range(1, len(tmp)):
        k[i].append(int(tmp[j]))

dict = {}
for i in range(1, m+1):
    dict[i] = 0

for i in k:
    for j in i:
        dict[j] += 1

cnt = 0
for i in range(1, m+1):
    if dict[i] == n:
        cnt += 1

print(cnt)
 n, m = input().split(" ") n input().split(" ") ().split () input split " " m n = int(n) n int(n) int n m = int(m) m int(m) int m k = [] k [] for i in range(n):
    k.append([])
    tmp = input().split(" ")
    for j in range(1, len(tmp)):
        k[i].append(int(tmp[j])) i range(n) range n k.append([]) k.append k append [] tmp = input().split(" ") tmp input().split(" ") ().split () input split " " for j in range(1, len(tmp)):
        k[i].append(int(tmp[j])) j range(1, len(tmp)) range 1 len(tmp) len tmp k[i].append(int(tmp[j])) [i].append [i] k i append int(tmp[j]) int tmp[j] tmp j dict = {} dict {} for i in range(1, m+1):
    dict[i] = 0 i range(1, m+1) range 1 m+1 m 1 dict[i] = 0 dict[i] dict i 0 for i in k:
    for j in i:
        dict[j] += 1 i k for j in i:
        dict[j] += 1 j i dict[j] += 1 dict[j] dict j 1 cnt = 0 cnt 0 for i in range(1, m+1):
    if dict[i] == n:
        cnt += 1 i range(1, m+1) range 1 m+1 m 1 if dict[i] == n:
        cnt += 1 dict[i] == n dict[i] dict i n cnt += 1 cnt 1 print(cnt) print cnt n = int(n) int(n) n tmp = input().split(" ") input().split(" ") tmp n, m = input().split(" ") input().split(" ") n m = int(m) int(m) m dict = {} {} dict cnt += 1 1 cnt m = input().split(" ") input().split(" ") m k = [] [] k cnt = 0 0 cnt
n, m = input().split(" ")
n = int(n)
m = int(m)
k = []
for i in range(n):
    k.append([])
    tmp = input().split(" ")
    for j in range(1, len(tmp)):
        k[i].append(int(tmp[j]))

dict = {}
for i in range(1, m+1):
    dict[i] = 0

for i in k:
    for j in i:
        dict[j] += 1

cnt = 0
for i in range(1, m+1):
    if dict[i] == n:
        cnt += 1

print(cnt)

