n, m = map(int, input().split())
f = [i for i in range(1, m + 1)]
for i in range(n):
  a = list(map(int, input().split()))
  k = a[0]
  a = a[1:]
  f = set(f) & set(a)
f = list(f)
print(len(f)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m i for i in range(1, m + 1) for i in range(1, m + 1) i range(1, m + 1) range 1 m + 1 m 1 for i in range(1, m + 1) i f = [i for i in range(1, m + 1)] f [i for i in range(1, m + 1)] for i in range(n):
  a = list(map(int, input().split()))
  k = a[0]
  a = a[1:]
  f = set(f) & set(a) 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 k = a[0] k a[0] a 0 a = a[1:] a a[1:] a 1: 1 f = set(f) & set(a) f set(f) & set(a) set(f) set f set(a) set a f = list(f) f list(f) list f print(len(f)) print len(f) len f f = [i for i in range(1, m + 1)] [i for i in range(1, m + 1)] f m = map(int, input().split()) map(int, input().split()) m f = list(f) list(f) f n, m = map(int, input().split()) map(int, input().split()) n k = a[0] a[0] k f = set(f) & set(a) set(f) & set(a) f a = list(map(int, input().split())) list(map(int, input().split())) a a = a[1:] a[1:] a
n, m = map(int, input().split())
f = [i for i in range(1, m + 1)]
for i in range(n):
  a = list(map(int, input().split()))
  k = a[0]
  a = a[1:]
  f = set(f) & set(a)
f = list(f)
print(len(f))