import numpy as np
n,m = map(int, input().split())
arr = np.zeros(m)
for i in range(n):
    ka = np.array([int(i) for i in input().split()])
    for j in range(ka[0]):
        arr[ka[j+1]-1] += 1
ans = (arr == n).sum()
print(ans) import numpy as np numpy n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m arr = np.zeros(m) arr np.zeros(m) np.zeros np zeros m for i in range(n):
    ka = np.array([int(i) for i in input().split()])
    for j in range(ka[0]):
        arr[ka[j+1]-1] += 1 i range(n) range n int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i ka = np.array([int(i) for i in input().split()]) ka np.array([int(i) for i in input().split()]) np.array np array [int(i) for i in input().split()] for j in range(ka[0]):
        arr[ka[j+1]-1] += 1 j range(ka[0]) range ka[0] ka 0 arr[ka[j+1]-1] += 1 arr[ka[j+1]-1] arr ka[j+1]-1 ka[j+1] ka j+1 j 1 1 1 ans = (arr == n).sum() ans (arr == n).sum() arr == n).sum arr == n arr n sum print(ans) print ans arr = np.zeros(m) np.zeros(m) arr m = map(int, input().split()) map(int, input().split()) m ka = np.array([int(i) for i in input().split()]) np.array([int(i) for i in input().split()]) ka n,m = map(int, input().split()) map(int, input().split()) n ans = (arr == n).sum() (arr == n).sum() ans
import numpy as np
n,m = map(int, input().split())
arr = np.zeros(m)
for i in range(n):
    ka = np.array([int(i) for i in input().split()])
    for j in range(ka[0]):
        arr[ka[j+1]-1] += 1
ans = (arr == n).sum()
print(ans)