def actual(N, M, K, A):
    # 各人のAの積集合の要素数が答え
    s = set(A[0])

    for a in A[1:]:
        s &= set(a)

    return len(s)


N, M = map(int, input().split())

K = []
A = []

for _ in range(N):
    ka = list(map(int, input().split()))
    K.append(ka[0])
    A.append(ka[1:])

print(actual(N, M, K, A)) def actual(N, M, K, A):
    # 各人のAの積集合の要素数が答え
    s = set(A[0])

    for a in A[1:]:
        s &= set(a)

    return len(s) actual s = set(A[0]) s set(A[0]) set A[0] A 0 for a in A[1:]:
        s &= set(a)

     a A[1:] A 1: 1 s &= set(a) s set(a) set a return len(s) len(s) len s N N M M K K A A N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M K = [] K [] A = [] A [] for _ in range(N):
    ka = list(map(int, input().split()))
    K.append(ka[0])
    A.append(ka[1:]) _ range(N) range N ka = list(map(int, input().split())) ka list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K.append(ka[0]) K.append K append ka[0] ka 0 A.append(ka[1:]) A.append A append ka[1:] ka 1: 1 print(actual(N, M, K, A)) print actual(N, M, K, A) actual N M K A A = [] [] A N, M = map(int, input().split()) map(int, input().split()) N ka = list(map(int, input().split())) list(map(int, input().split())) ka def actual(N, M, K, A):
    # 各人のAの積集合の要素数が答え
    s = set(A[0])

    for a in A[1:]:
        s &= set(a)

    return len(s) def actual(N, M, K, A):
    # 各人のAの積集合の要素数が答え
    s = set(A[0])

    for a in A[1:]:
        s &= set(a)

    return len(s) actual K = [] [] K M = map(int, input().split()) map(int, input().split()) M
def actual(N, M, K, A):
    # 各人のAの積集合の要素数が答え
    s = set(A[0])

    for a in A[1:]:
        s &= set(a)

    return len(s)


N, M = map(int, input().split())

K = []
A = []

for _ in range(N):
    ka = list(map(int, input().split()))
    K.append(ka[0])
    A.append(ka[1:])

print(actual(N, M, K, A))
