n, m = map(int, input().split())
a = set(range(1, m + 1))
for _ in range(n):
    a &= set(list(map(int, input().split()))[1:])
print(len(a)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a = set(range(1, m + 1)) a set(range(1, m + 1)) set range(1, m + 1) range 1 m + 1 m 1 for _ in range(n):
    a &= set(list(map(int, input().split()))[1:]) _ range(n) range n a &= set(list(map(int, input().split()))[1:]) a set(list(map(int, input().split()))[1:]) set list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 1: 1 print(len(a)) print len(a) len a a &= set(list(map(int, input().split()))[1:]) set(list(map(int, input().split()))[1:]) a m = map(int, input().split()) map(int, input().split()) m a = set(range(1, m + 1)) set(range(1, m + 1)) a n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
a = set(range(1, m + 1))
for _ in range(n):
    a &= set(list(map(int, input().split()))[1:])
print(len(a))
