n, m = map(int, input().split())
foods = [0 for _ in range(m + 1)]
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(1, a[0] + 1):
        foods[a[j]] += 1
print(foods.count(n)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m 0 for _ in range(m + 1) for _ in range(m + 1) _ range(m + 1) range m + 1 m 1 for _ in range(m + 1) 0 foods = [0 for _ in range(m + 1)] foods [0 for _ in range(m + 1)] for i in range(n):
    a = list(map(int, input().split()))
    for j in range(1, a[0] + 1):
        foods[a[j]] += 1 i range(n) range n a = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for j in range(1, a[0] + 1):
        foods[a[j]] += 1 j range(1, a[0] + 1) range 1 a[0] + 1 a[0] a 0 1 foods[a[j]] += 1 foods[a[j]] foods a[j] a j 1 print(foods.count(n)) print foods.count(n) foods.count foods count n a = list(map(int, input().split())) list(map(int, input().split())) a m = map(int, input().split()) map(int, input().split()) m foods = [0 for _ in range(m + 1)] [0 for _ in range(m + 1)] foods n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
foods = [0 for _ in range(m + 1)]
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(1, a[0] + 1):
        foods[a[j]] += 1
print(foods.count(n))