#!/usr/bin/env python3
n, m = map(int, input().split())
ans = set(x for x in range(1, m+1))
for i in range(n):
    k, *a = map(int, input().split())
    ans = set(a) & ans
print(len(ans)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ans = set(x for x in range(1, m+1)) ans set(x for x in range(1, m+1)) set x for i in range(n):
    k, *a = map(int, input().split())
    ans = set(a) & ans 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 ans = set(a) & ans ans set(a) & ans set(a) set a ans print(len(ans)) print len(ans) len ans m = map(int, input().split()) map(int, input().split()) m ans = set(a) & ans set(a) & ans ans ans = set(x for x in range(1, m+1)) set(x for x in range(1, m+1)) ans n, m = map(int, input().split()) map(int, input().split()) n k, *a = map(int, input().split()) map(int, input().split()) k
#!/usr/bin/env python3
n, m = map(int, input().split())
ans = set(x for x in range(1, m+1))
for i in range(n):
    k, *a = map(int, input().split())
    ans = set(a) & ans
print(len(ans))
