N, M = map(int, input().split())
c = []
ans = 0
for i in range(N):
    tmp = list(map(int, input().split()))
    c.extend(tmp[1:])
cnt = [0 for i in range(M)]
for i in range(len(c)):
    tmp2 = c[i]-1
    cnt[tmp2] += 1

for i in range(M):
    if cnt[i] == N:
        ans += 1

print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M c = [] c [] ans = 0 ans 0 for i in range(N):
    tmp = list(map(int, input().split()))
    c.extend(tmp[1:]) i range(N) range N tmp = list(map(int, input().split())) tmp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c.extend(tmp[1:]) c.extend c extend tmp[1:] tmp 1: 1 0 for i in range(M) for i in range(M) i range(M) range M for i in range(M) 0 cnt = [0 for i in range(M)] cnt [0 for i in range(M)] for i in range(len(c)):
    tmp2 = c[i]-1
    cnt[tmp2] += 1 i range(len(c)) range len(c) len c tmp2 = c[i]-1 tmp2 c[i]-1 c[i] c i 1 cnt[tmp2] += 1 cnt[tmp2] cnt tmp2 1 for i in range(M):
    if cnt[i] == N:
        ans += 1 i range(M) range M if cnt[i] == N:
        ans += 1 cnt[i] == N cnt[i] cnt i N ans += 1 ans 1 print(ans) print ans N, M = map(int, input().split()) map(int, input().split()) N tmp2 = c[i]-1 c[i]-1 tmp2 tmp = list(map(int, input().split())) list(map(int, input().split())) tmp c = [] [] c ans = 0 0 ans cnt = [0 for i in range(M)] [0 for i in range(M)] cnt M = map(int, input().split()) map(int, input().split()) M ans += 1 1 ans
N, M = map(int, input().split())
c = []
ans = 0
for i in range(N):
    tmp = list(map(int, input().split()))
    c.extend(tmp[1:])
cnt = [0 for i in range(M)]
for i in range(len(c)):
    tmp2 = c[i]-1
    cnt[tmp2] += 1

for i in range(M):
    if cnt[i] == N:
        ans += 1

print(ans)