n,m=map(int,input().split())
ka= [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    ka[i].pop(0)
ans = ka[0]
for i in range(1,n):
    ans = set(ans) & set(ka[i])
print(len(ans)) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ka= [list(map(int,input().split())) for i in range(n)] ka [list(map(int,input().split())) for i in range(n)] for i in range(n):
    ka[i].pop(0) i range(n) range n ka[i].pop(0) [i].pop [i] ka i pop 0 ans = ka[0] ans ka[0] ka 0 for i in range(1,n):
    ans = set(ans) & set(ka[i]) i range(1,n) range 1 n ans = set(ans) & set(ka[i]) ans set(ans) & set(ka[i]) set(ans) set ans set(ka[i]) set ka[i] ka i print(len(ans)) print len(ans) len ans ans = ka[0] ka[0] ans ans = set(ans) & set(ka[i]) set(ans) & set(ka[i]) ans m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n ka= [list(map(int,input().split())) for i in range(n)] [list(map(int,input().split())) for i in range(n)] ka
n,m=map(int,input().split())
ka= [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    ka[i].pop(0)
ans = ka[0]
for i in range(1,n):
    ans = set(ans) & set(ka[i])
print(len(ans))