N, M = map(int, input().split())
s = set()
for i in range(N):
    K, *A = map(int, input().split())
    if i == 0:
        s = set(A)
    else:
        t = set(A)
        s = s.intersection(t)
print(len(s)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M s = set() s set() set for i in range(N):
    K, *A = map(int, input().split())
    if i == 0:
        s = set(A)
    else:
        t = set(A)
        s = s.intersection(t) i range(N) range N K, *A = map(int, input().split()) K map(int, input().split()) map int input().split() ().split () input split *A A if i == 0:
        s = set(A)
    else:
        t = set(A)
        s = s.intersection(t) i == 0 i 0 s = set(A) s set(A) set A t = set(A) t set(A) set A s = s.intersection(t) s s.intersection(t) s.intersection s intersection t print(len(s)) print len(s) len s M = map(int, input().split()) map(int, input().split()) M s = set(A) set(A) s t = set(A) set(A) t N, M = map(int, input().split()) map(int, input().split()) N K, *A = map(int, input().split()) map(int, input().split()) K s = s.intersection(t) s.intersection(t) s s = set() set() s
N, M = map(int, input().split())
s = set()
for i in range(N):
    K, *A = map(int, input().split())
    if i == 0:
        s = set(A)
    else:
        t = set(A)
        s = s.intersection(t)
print(len(s))