def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N, M = MI()
love = [0] * M
ans = 0

for i in range(N):
    K, *A = MI()
    for a in A:
        love[a - 1] += 1
    
for l in love:
    if l == N:
        ans += 1

print(ans) def MI():
    return map(int, input().split()) MI return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def LI():
    return list(map(int, input().split())) LI return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split N, M = MI() N MI() MI M love = [0] * M love [0] * M [0] 0 M ans = 0 ans 0 for i in range(N):
    K, *A = MI()
    for a in A:
        love[a - 1] += 1
     i range(N) range N K, *A = MI() K MI() MI *A A for a in A:
        love[a - 1] += 1
     a A love[a - 1] += 1 love[a - 1] love a - 1 a 1 1 for l in love:
    if l == N:
        ans += 1 l love if l == N:
        ans += 1 l == N l N ans += 1 ans 1 print(ans) print ans N, M = MI() MI() N ans += 1 1 ans love = [0] * M [0] * M love M = MI() MI() M ans = 0 0 ans def MI():
    return map(int, input().split()) def MI():
    return map(int, input().split()) MI K, *A = MI() MI() K def LI():
    return list(map(int, input().split())) def LI():
    return list(map(int, input().split())) LI
def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N, M = MI()
love = [0] * M
ans = 0

for i in range(N):
    K, *A = MI()
    for a in A:
        love[a - 1] += 1
    
for l in love:
    if l == N:
        ans += 1

print(ans)