# B - Foods Loved by Everyone
from collections import deque
N,M = map(int,input().split())
K = []
A = []
for o in range(N):
    KA = deque(list(map(int,input().split())))
    Ki = KA.popleft()
    K.append(Ki)
    A.append(list(KA))

common = [0]*(M+1)
for i in A:
    for j in i:
        common[j] += 1
count = 0
for k in common:
    if k == N:
        count += 1
print(count)     from collections import deque N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M K = [] K [] A = [] A [] for o in range(N):
    KA = deque(list(map(int,input().split())))
    Ki = KA.popleft()
    K.append(Ki)
    A.append(list(KA)) o range(N) range N KA = deque(list(map(int,input().split()))) KA deque(list(map(int,input().split()))) deque list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split Ki = KA.popleft() Ki KA.popleft() KA.popleft KA popleft K.append(Ki) K.append K append Ki A.append(list(KA)) A.append A append list(KA) list KA common = [0]*(M+1) common [0]*(M+1) [0] 0 M+1 M 1 for i in A:
    for j in i:
        common[j] += 1 i A for j in i:
        common[j] += 1 j i common[j] += 1 common[j] common j 1 count = 0 count 0 for k in common:
    if k == N:
        count += 1 k common if k == N:
        count += 1 k == N k N count += 1 count 1 print(count) print count Ki = KA.popleft() KA.popleft() Ki KA = deque(list(map(int,input().split()))) deque(list(map(int,input().split()))) KA N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M count += 1 1 count common = [0]*(M+1) [0]*(M+1) common K = [] [] K A = [] [] A count = 0 0 count
# B - Foods Loved by Everyone
from collections import deque
N,M = map(int,input().split())
K = []
A = []
for o in range(N):
    KA = deque(list(map(int,input().split())))
    Ki = KA.popleft()
    K.append(Ki)
    A.append(list(KA))

common = [0]*(M+1)
for i in A:
    for j in i:
        common[j] += 1
count = 0
for k in common:
    if k == N:
        count += 1
print(count)    