n,m = map(int,input().split())
data = [0]*n
for i in range(n):
    data[i] = input().split()
ans = 0
if n == 1:
    print(len(data[0]) - 1)
else:
    for i in range(1,int(data[0][0]) + 1):
        bool = True
        for j in range(1,n):
            if data[0][i] not in data[j][1:]:
                bool = False
        if bool:
            ans += 1
    print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m data = [0]*n data [0]*n [0] 0 n for i in range(n):
    data[i] = input().split() i range(n) range n data[i] = input().split() data[i] data i input().split() ().split () input split ans = 0 ans 0 if n == 1:
    print(len(data[0]) - 1)
else:
    for i in range(1,int(data[0][0]) + 1):
        bool = True
        for j in range(1,n):
            if data[0][i] not in data[j][1:]:
                bool = False
        if bool:
            ans += 1
    print(ans) n == 1 n 1 print(len(data[0]) - 1) print len(data[0]) - 1 len(data[0]) len data[0] data 0 1 for i in range(1,int(data[0][0]) + 1):
        bool = True
        for j in range(1,n):
            if data[0][i] not in data[j][1:]:
                bool = False
        if bool:
            ans += 1
     i range(1,int(data[0][0]) + 1) range 1 int(data[0][0]) + 1 int(data[0][0]) int data[0][0] [0] data 0 0 1 bool = True bool True for j in range(1,n):
            if data[0][i] not in data[j][1:]:
                bool = False
         j range(1,n) range 1 n if data[0][i] not in data[j][1:]:
                bool = False
         data[0][i] not in data[j][1:] data[0][i] [0] data 0 i data[j][1:] [j] data j 1: 1 bool = False bool False if bool:
            ans += 1
     bool ans += 1 ans 1 print(ans) print ans ans += 1 1 ans data = [0]*n [0]*n data ans = 0 0 ans bool = False False bool m = map(int,input().split()) map(int,input().split()) m n,m = map(int,input().split()) map(int,input().split()) n bool = True True bool
n,m = map(int,input().split())
data = [0]*n
for i in range(n):
    data[i] = input().split()
ans = 0
if n == 1:
    print(len(data[0]) - 1)
else:
    for i in range(1,int(data[0][0]) + 1):
        bool = True
        for j in range(1,n):
            if data[0][i] not in data[j][1:]:
                bool = False
        if bool:
            ans += 1
    print(ans)