import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

kyoutu = []

for i in range(1,31):
    kyoutu.append(i)

for _ in range(n):
    A = inintl()
    t = A[1:]
    kyoutu = set(kyoutu) & set(t)

print(len(kyoutu)) import sys sys inint = lambda: int(sys.stdin.readline()) inint lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline inintm = lambda: map(int, sys.stdin.readline().split()) inintm lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split inintl = lambda: list(inintm()) inintl lambda: list(inintm()) list(inintm()) list inintm() inintm instrm = lambda: map(str, sys.stdin.readline().split()) instrm lambda: map(str, sys.stdin.readline().split()) map(str, sys.stdin.readline().split()) map str sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split instrl = lambda: list(instrm()) instrl lambda: list(instrm()) list(instrm()) list instrm() instrm n, m = inintm() n inintm() inintm m kyoutu = [] kyoutu [] for i in range(1,31):
    kyoutu.append(i) i range(1,31) range 1 31 kyoutu.append(i) kyoutu.append kyoutu append i for _ in range(n):
    A = inintl()
    t = A[1:]
    kyoutu = set(kyoutu) & set(t) _ range(n) range n A = inintl() A inintl() inintl t = A[1:] t A[1:] A 1: 1 kyoutu = set(kyoutu) & set(t) kyoutu set(kyoutu) & set(t) set(kyoutu) set kyoutu set(t) set t print(len(kyoutu)) print len(kyoutu) len kyoutu inint = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) inint kyoutu = set(kyoutu) & set(t) set(kyoutu) & set(t) kyoutu inintl = lambda: list(inintm()) lambda: list(inintm()) inintl instrl = lambda: list(instrm()) lambda: list(instrm()) instrl A = inintl() inintl() A inintm = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) inintm n, m = inintm() inintm() n m = inintm() inintm() m kyoutu = [] [] kyoutu instrm = lambda: map(str, sys.stdin.readline().split()) lambda: map(str, sys.stdin.readline().split()) instrm t = A[1:] A[1:] t
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

kyoutu = []

for i in range(1,31):
    kyoutu.append(i)

for _ in range(n):
    A = inintl()
    t = A[1:]
    kyoutu = set(kyoutu) & set(t)

print(len(kyoutu))