def main():
    n,m = map(int,input().split())
    a = []
    for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
    l = [0 for i in range(m)]
    for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
    ans = 0
    for i in range(m):
        if l[i] == n:
            ans += 1
    print(ans)

main() def main():
    n,m = map(int,input().split())
    a = []
    for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
    l = [0 for i in range(m)]
    for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
    ans = 0
    for i in range(m):
        if l[i] == n:
            ans += 1
    print(ans) main n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a = [] a [] for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
     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 tmp = [int(i) for i in input().split()] tmp [int(i) for i in input().split()] a.append(tmp) a.append a append tmp 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 l = [0 for i in range(m)] l [0 for i in range(m)] for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
     i range(n) range n k = a[i][0] k a[i][0] [i] a i 0 for j in range(1,k+1):
            l[a[i][j]-1] +=1
     j range(1,k+1) range 1 k+1 k 1 l[a[i][j]-1] +=1 l[a[i][j]-1] l a[i][j]-1 a[i][j] [i] a i j 1 1 ans = 0 ans 0 for i in range(m):
        if l[i] == n:
            ans += 1
     i range(m) range m if l[i] == n:
            ans += 1
     l[i] == n l[i] l i n ans += 1 ans 1 print(ans) print ans main() main def main():
    n,m = map(int,input().split())
    a = []
    for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
    l = [0 for i in range(m)]
    for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
    ans = 0
    for i in range(m):
        if l[i] == n:
            ans += 1
    print(ans) def main():
    n,m = map(int,input().split())
    a = []
    for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
    l = [0 for i in range(m)]
    for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
    ans = 0
    for i in range(m):
        if l[i] == n:
            ans += 1
    print(ans) main
def main():
    n,m = map(int,input().split())
    a = []
    for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
    l = [0 for i in range(m)]
    for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
    ans = 0
    for i in range(m):
        if l[i] == n:
            ans += 1
    print(ans)

main()