n,m =  map(int,input().split())
k = []
cnt = 0

for i in range(n):
    tmp = input().split()
    tmp.pop(0)
    k += tmp

for i in range(m):
    if k.count(str(i+1)) == n:
        cnt += 1

print(cnt) n,m =  map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m k = [] k [] cnt = 0 cnt 0 for i in range(n):
    tmp = input().split()
    tmp.pop(0)
    k += tmp i range(n) range n tmp = input().split() tmp input().split() ().split () input split tmp.pop(0) tmp.pop tmp pop 0 k += tmp k tmp for i in range(m):
    if k.count(str(i+1)) == n:
        cnt += 1 i range(m) range m if k.count(str(i+1)) == n:
        cnt += 1 k.count(str(i+1)) == n k.count(str(i+1)) k.count k count str(i+1) str i+1 i 1 n cnt += 1 cnt 1 print(cnt) print cnt m =  map(int,input().split()) map(int,input().split()) m cnt += 1 1 cnt tmp = input().split() input().split() tmp k = [] [] k n,m =  map(int,input().split()) map(int,input().split()) n k += tmp tmp k cnt = 0 0 cnt
n,m =  map(int,input().split())
k = []
cnt = 0

for i in range(n):
    tmp = input().split()
    tmp.pop(0)
    k += tmp

for i in range(m):
    if k.count(str(i+1)) == n:
        cnt += 1

print(cnt)