a = list(map(int,input().split()))

N = a[0]
M = a[1]

ctr = [0 for i in range(M)]


for i in range(N):
    b =  list(map(int,input().split()))

    for j in range(b[0]):
        for k in range(M):
            if b[j+1] == k+1:
                ctr[k] += 1

flag = [N == ctr[j] for j in range(M)]
print(sum(flag)) a = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split N = a[0] N a[0] a 0 M = a[1] M a[1] a 1 0 for i in range(M) for i in range(M) i range(M) range M for i in range(M) 0 ctr = [0 for i in range(M)] ctr [0 for i in range(M)] for i in range(N):
    b =  list(map(int,input().split()))

    for j in range(b[0]):
        for k in range(M):
            if b[j+1] == k+1:
                ctr[k] += 1 i range(N) range N b =  list(map(int,input().split())) b list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in range(b[0]):
        for k in range(M):
            if b[j+1] == k+1:
                ctr[k] += 1 j range(b[0]) range b[0] b 0 for k in range(M):
            if b[j+1] == k+1:
                ctr[k] += 1 k range(M) range M if b[j+1] == k+1:
                ctr[k] += 1 b[j+1] == k+1 b[j+1] b j+1 j 1 k+1 k 1 ctr[k] += 1 ctr[k] ctr k 1 N == ctr[j] for j in range(M) for j in range(M) j range(M) range M for j in range(M) N == ctr[j] N ctr[j] ctr j flag = [N == ctr[j] for j in range(M)] flag [N == ctr[j] for j in range(M)] print(sum(flag)) print sum(flag) sum flag ctr = [0 for i in range(M)] [0 for i in range(M)] ctr a = list(map(int,input().split())) list(map(int,input().split())) a b =  list(map(int,input().split())) list(map(int,input().split())) b N = a[0] a[0] N flag = [N == ctr[j] for j in range(M)] [N == ctr[j] for j in range(M)] flag M = a[1] a[1] M
a = list(map(int,input().split()))

N = a[0]
M = a[1]

ctr = [0 for i in range(M)]


for i in range(N):
    b =  list(map(int,input().split()))

    for j in range(b[0]):
        for k in range(M):
            if b[j+1] == k+1:
                ctr[k] += 1

flag = [N == ctr[j] for j in range(M)]
print(sum(flag))