from collections import Counter
n, m = map(int, input().split())
l = []
for _ in range(n):
    k, *a = map(int, input().split())
    l += a
c = Counter(l)

cnt = 0
for val in c.values():
  if val == n:
    cnt += 1
print(cnt) from collections import Counter n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l = [] l [] for _ in range(n):
    k, *a = map(int, input().split())
    l += a _ range(n) range n k, *a = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *a a l += a l a c = Counter(l) c Counter(l) Counter l cnt = 0 cnt 0 for val in c.values():
  if val == n:
    cnt += 1 val c.values() c.values c values if val == n:
    cnt += 1 val == n val n cnt += 1 cnt 1 print(cnt) print cnt m = map(int, input().split()) map(int, input().split()) m k, *a = map(int, input().split()) map(int, input().split()) k l += a a l cnt = 0 0 cnt c = Counter(l) Counter(l) c n, m = map(int, input().split()) map(int, input().split()) n l = [] [] l cnt += 1 1 cnt
from collections import Counter
n, m = map(int, input().split())
l = []
for _ in range(n):
    k, *a = map(int, input().split())
    l += a
c = Counter(l)

cnt = 0
for val in c.values():
  if val == n:
    cnt += 1
print(cnt)